Home › Forums › Calendar Products › Events Calendar PRO › Hide category from view and on AJAX-loaded pages
- This topic has 4 replies, 2 voices, and was last updated 10 years, 7 months ago by
George.
-
AuthorPosts
-
October 6, 2015 at 2:41 pm #1012059
vitaldesign
ParticipantI’m using the recommended pre_get_posts filter to exclude a specific event category from all calendar views: https://theeventscalendar.com/knowledgebase/hide-category-from-calendar-views/ This works, however it does NOT work when clicking on Next/Previous events links because they are loaded via AJAX.
How can I get this to work? Disabling the AJAX-loaded pagination is also an acceptible solution!
Site example: https://nhfilmfestival.com/events
October 7, 2015 at 5:56 am #1012204George
ParticipantHey @vitaldesign,
What’s the name of the category you are trying to hide? A simple solution here might be to add a second layer of hiding that category, but this time with CSS. This way, there’s a secondary layer of code on your site in the CSS so that if an event in this category is on the page, it will be hidden completely.
I recommend this because doing more PHP work to try and prevent it coming in from AJAX, and/or stopping the AJAX pagination altogether, are a bit more complicated than this simple CSS tweak. And these former 2 customization ideas would also be significantly harder to maintain over time and could break other things on your site unintentionally….
Let me know what you think about this! If the category you want to hide is called “bad movies”, or something, for example, then the trick we’ll be doing here is just using the class name .tribe-events-category-bad-movies to hide anything with that category on your site.
Cheers!
GeorgeOctober 10, 2015 at 8:26 am #1013443vitaldesign
ParticipantI’m a web developer, so I’m perfectly okay with (and prefer) altering the query/behavior. If I can’t find a native way to filter the query, I’ll probably just resort to a pre_get_posts or WP_Query to get the content I want.
Hiding the items with CSS will just mess up the pagination, giving me pages without the full count of posts and some pages would appear completely empty.
October 10, 2015 at 9:34 am #1013448vitaldesign
ParticipantWell! It looks like some kind of caching on our server may have been preventing my pre_get_posts filter from working when I originally opened this thread! I am now seeing my filtered events as they should be. Thank you for your help!
October 12, 2015 at 1:53 pm #1013833George
ParticipantWell! It looks like some kind of caching on our server may have been preventing my pre_get_posts filter from working when I originally opened this thread
Weird! Glad you found out what the behavior was finally – best of luck with your site going forward! 🙂
— George
-
AuthorPosts
- The topic ‘Hide category from view and on AJAX-loaded pages’ is closed to new replies.
