Exclude Recurring Events from Search Results Except 1 instance

Home Forums Calendar Products Events Calendar PRO Exclude Recurring Events from Search Results Except 1 instance

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #642684
    communityanswers
    Participant

    Hello – We tried this snippet (https://tri.be/support/forums/topic/exclude-recurring-events-during-blog-loop-event-integration/) which does NOT work.

    I need a function to EXCLUDE the RECURRING events from SITE SEARCH RESULTS except 1 instance (the most recent/upcoming).

    Can you please provide the code to do that or point us in that direction.

    There is an option in ECP Genera; Settings labeled: Recurring event instances – [] Show only the first instance of each recurring event (only affects list-style views). Is it possible to use that somehow?

    Thank you.

    #651758
    Barry
    Member

    Hi – I’m sorry you’re experiencing difficulties.

    The snippet you referenced is not actually intended to impact on search results, rather it specifically targets the main blog loop.

    if ( $query->is_main_query() && is_home() ) /* ... */

    It actually tests to see if a number of conditions are true – the first being a check to see if we’re in the main query and the second to detect if it is a home page request. Those may not be true in a search query, but you could certainly tailor this further if you need to.

    Have you checked out the WP_Query docs? They go into more detail about how to interact with these sorts of properties:

    Does that help?

     

    #653348
    communityanswers
    Participant

    Thanks. Unfortunately, that does not help. I’m quite familiar with the WP_Query and already messed with it. The problem is how to tackle the ECP logic of recurring events and showing only one instance. That has nothing to do with the main query, but rather the arguments required to exclude ECP records.

    For example, you have an option in ECP Settings > “Recurring event instances – [] Show only the first instance of each recurring event (only affects list-style views)”

    Why not just create an option to show only 1 instance of recurring events in search results. (why only list-view?)

    Regardless, is it possible to at least provide us the logic / code that can be leveraged in a search query to exclude recurring events except a single instance? Can you please provide how we can use the same logic already being used in that setting?

    Thank you.

    #658406
    Barry
    Member

    Hi!

    Why not just create an option to show only 1 instance of recurring events in search results. (why only list-view?)

    Generally speaking it doesn’t make as much sense to apply this setting to views like month view: applying this setting across the board therefore could cause some confusion which is why it is applied only to list-style views.

    Regardless, is it possible to at least provide us the logic / code that can be leveraged in a search query to exclude recurring events except a single instance?

    It actually seems to do pretty much this already – if you enable the setting you referenced then you should only see one instance of a given recurring event.

    The only potential problem I see is that if the sequence of recurring events started in the past then it may be the oldest event which appears, rather than the next upcoming event. Just to clarify, is that the problem you need to resolve here, or are you finding the setting is no impact whatsoever (and are seeing multiple recurring events)?

    #661839
    communityanswers
    Participant

    Problem: Say you have many recurring events (some daily). Take for example, an event titled “WordPress Workshop”

    Now, a visitor types into standard WP search box the search term: “WordPress”

    The results will be all events that have that word in it. The search results include *EVERY* recurring event (each day, same event over and over).

    What we want is that the search results only in the next UPCOMING “WordPress Workshop””, not all 365 instances of it.

    How do we achieve that? Can you provide some guidance as to how you are excluding all recurring events in the unrelated ECP setting I referenced earlier.

    I assume the end solution has to use the pre_get_posts filter.

    add_filter( ‘pre_get_posts’…

    Thx.

    #662300
    Barry
    Member

    What we want is that the search results only in the next UPCOMING “WordPress Workshop””, not all 365 instances of it.

    Right, so we’re seeing something different.

    Though not perfect, what I see when the show only the first instance of each recurring event (only affects list-style views) setting is enabled is only the first of each recurring event (when someone searches via the main WordPress search).

    It sounds like you are seeing all of them and that’s a little unexpected.

    YES, I’ve deactivated all other plugins to check for a plugin conflict.
    YES, I’ve reverted to the 2011 default WordPress theme (with other plugins still deactivated) to check for a theme conflict.

    When you created this thread you noted having run through the above troubleshooting steps which is awesome. Did you see the same thing under those conditions? I’d like to be doubly sure as this isn’t something I can replicate locally.

    #723438
    Barry
    Member

    Hi! It’s been a while so I’m going to go ahead and close this thread. If we can help with anything else, though, please don’t hesitate to create new threads as needed. Thanks!

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Exclude Recurring Events from Search Results Except 1 instance’ is closed to new replies.