Home › Forums › Calendar Products › Events Calendar PRO › Hide date/time if in category
- This topic has 8 replies, 4 voices, and was last updated 9 years, 10 months ago by
Mylene Bruneau.
-
AuthorPosts
-
June 13, 2016 at 7:54 pm #1126512
Mylene Bruneau
ParticipantI 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 ?
June 13, 2016 at 9:12 pm #1126528Mylene Bruneau
ParticipantOK 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!June 14, 2016 at 12:08 pm #1126924Geoff
MemberHey 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!
GeoffJune 15, 2016 at 8:39 am #1127319Mylene Bruneau
ParticipantThanks, 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
June 15, 2016 at 9:49 am #1127410Geoff
MemberHey 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!
GeoffJune 16, 2016 at 6:48 am #1127849Mylene Bruneau
ParticipantI 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.June 16, 2016 at 7:09 am #1127861Geoff
MemberOh sorry, I should have mentioned that is an optional value — the label alone should do the trick.
July 1, 2016 at 9:35 am #1134505Support Droid
KeymasterThis 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. -
AuthorPosts
- The topic ‘Hide date/time if in category’ is closed to new replies.
