Search function – how to create a search bar

Home Forums Calendar Products Events Calendar PRO Search function – how to create a search bar

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1022310
    Susan Armstrong
    Participant

    I have inherited a site that already had The Events Cal Pro version. I am trying to understand the search feature in the calendar. They want a search feature for events but for the life of me I cannot figure out how to get the events to show up on a results page.

    I have also added the following common function to my themes function page without success.
    // Define what post types to include in search
    function include_in_search( $query ) {
    if ( $query->is_search ) {
    $query->set( ‘post_type’, array( ‘post’, ‘page’, ‘feed’, ‘tribe_events’ ));
    }
    return $query;
    }
    add_filter( ‘the_search_query’, ‘include_in_search’ );

    I have considered the possibility of the filter bar add-on but I am hesitant to do so.
    I have a concern that the initial setup of the calendar is not correct. for example the events slug is not plural and is the same as the single event how will this truly affect the operations? I know I am a bit all over the place but I have spent a lot of time on this. Any insight would be greatly appreciated.

    #1022432
    Brook
    Participant

    Howdy armstrongchamberlin,

    I would love to help you with this.

    I have a concern that the initial setup of the calendar is not correct. for example the events slug is not plural and is the same as the single event how will this truly affect the operations

    That is not great. If possible I would change it to be a plural. There are numerous issues that can arise, particularly if one of your event slugs contains something like ‘list’ or ‘map’.

    function include_in_search( $query ) {
    if ( $query->is_search ) {
    $query->set( ‘post_type’, array( ‘post’, ‘page’, ‘feed’, ‘tribe_events’ ));
    }
    return $query;
    }
    add_filter( ‘the_search_query’, ‘include_in_search’ );

    It is quite possible that something is overriding your post_type after you set it here. There are so many things that could go wrong I just can’t be of much help telling you why this custom code isn’t working. 🙁 You might need to fire up a debugger like xdebug, then break on the_search_query and see all the code that is affecting it.

    Does that all make sense? Please let me know.

    Cheers!

    – Brook

    #1075445
    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 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Search function – how to create a search bar’ is closed to new replies.