Hide date/time if in category

Home Forums Calendar Products Events Calendar PRO Hide date/time if in category

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1126512
    Mylene Bruneau
    Participant

    I have events that exist without a date.
    They are available “on demand” but I would like them to appear in search results by category, etc. and to have the same look and feel as the rest of the website.

    BUT: I cannot enter them without a date.
    So I put a date in the past.
    AND I created a category “on demand” and I have a page that features them all. All fine.
    But is is confusing to the user because it still shows a date when they check out these events.

    When I look at my category page of ‘on demand’ events, I would like to hide
    <div class=”tribe-events-cta-date”> (Hide the date and time)
    I would need to hide it in list and in single
    But of course that page is used for all categories, and the date SHOULD appear for all events – except events that are in category “on demand”.

    Note that “on demand” events are also part of other categories.

    How to accomplish this ?

    #1126528
    Mylene Bruneau
    Participant

    OK so I put this in details.php
    <?php if (tribe_event_in_category(‘formation-sur-demande’)) { // show nothing ?>
    <?php } else { // show date and time ?>
    <?php } ?>
    It worked.
    Only thing left: The single page of an event still show a notice on top:
    The event has passed.

    Applying this same logic, I could hide this notice when category is “formation-sur-demande”, but I cannot find in which file this is generated…
    I’m close, any hint appreciated!

    #1126924
    Geoff
    Member

    Hey Mylene,

    You’re on the exact path I was going to suggest! Nice work. 🙂

    To get the notice off the single event in that specific category, try adding this snippet to your functions.php file. It seemed to do the trick when I tested it out on my own site.

    I do want to note that you might need to change the text for the notice in that snippet to match your site’s language. Whatever the exact notice is, use that in place of the “This events has passed.” text.

    Will this work for you? Please let me know.

    Cheers!
    Geoff

    #1127319
    Mylene Bruneau
    Participant

    Thanks, I will try that, but I have found a workaround where I changed the text to “The is available on demand” as a warning message.

    BUT I have another question:
    I added a custom field for the workshop number (example: 907)
    – I would like to show that number in the LIST page (https://cenopformation.com/formations/) next to the title. I found the file and location where to put my script, but I tried calling that value, to no avail. get_post_meta($post_id, ‘No Formation’, true); which is the WP call, but is it because I should use tribe_events call?
    – I managed to have that custom field column appear in admin, and to make it sortable. BUT when I click to sort it, the order is… whatever. 100 then 1003 then 700 then 307… Any idea why ?

    Also to those interested about events with no dates:
    1) I created a category for events “on demand”
    2) Assigned it to events, then put a date in the past
    3) Created an archive page for that category
    4) Masked the date in the list php page on condition (if category = on-demand then don’t show date)
    5) Also hid the date in the single page, on condition
    That way, I can have the same design / functionalities / category browsing for events with no dates.
    I did put a link in the event description to a simple form to request that workshop via email.

    Just be careful to put the date enough in the past that it won’t show up on the monthly view calendar

    #1127410
    Geoff
    Member

    Hey Mylene, thanks for following up!

    Custom fields are definitely tricky to call call, but can be using something like this:

    Tribe__Events__Pro__Custom_Meta::get_custom_field_by_label( $label, $eventID );

    Echo that and replace $label with the label for the workshop number custom field and that should give you the field. 🙂

    Will that work for you? Please let me know.

    Cheers!
    Geoff

    #1127849
    Mylene Bruneau
    Participant

    I don’t know how to get the $eventID value so that code gives me a fatal error…
    But thank! I think I’m done with my customization.

    #1127861
    Geoff
    Member

    Oh sorry, I should have mentioned that is an optional value — the label alone should do the trick.

    #1134505
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Hide date/time if in category’ is closed to new replies.