Hide category from view and on AJAX-loaded pages

Home Forums Calendar Products Events Calendar PRO Hide category from view and on AJAX-loaded pages

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1012059
    vitaldesign
    Participant

    I’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

    #1012204
    George
    Participant

    Hey @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!
    George

    #1013443
    vitaldesign
    Participant

    I’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.

    #1013448
    vitaldesign
    Participant

    Well! 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!

    #1013833
    George
    Participant

    Well! 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

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Hide category from view and on AJAX-loaded pages’ is closed to new replies.