Include events in default WordPress search

Home Forums Calendar Products Events Calendar PRO Include events in default WordPress search

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1200764
    Arno Hoogwerf
    Participant

    Is it possible to include my events from The Events Calendar PRO in the default WordPress search function (like ?s=[search])? My theme has a great search-bar which uses the normal WordPress search, only my events won’t show up. It would be great if those work together.

    #1201082
    George
    Participant

    Hey @arno,

    It’s unfortunately not possible to do this without custom coding beyond the scope of support. 🙁

    So to make this work as you describe, you would have to write that custom code or hire a professional developer to do it for you. We have a list of great developers here → http://m.tri.be/18k1 (and have no affiliation with any of these folks—they’re simply some well-respected names in the community that we’ve compiled to share in situations like this one).


    With all the above things being said, you might have some basic success by adding this custom code snippet that I wrote for you to your theme’s functions.php file:


    function tribe_add_events_to_search_results( $query ) {

    if ( ! is_admin() && $query->is_main_query() ) {

    if ( $query->is_search ) {
    $query->set('post_type', array( 'post', 'tribe_events' ) );
    }
    }
    }

    add_action( 'pre_get_posts', 'tribe_add_events_to_search_results' );

    ☝️ Let us know if this helps at all!

    — George

    #1201319
    Arno Hoogwerf
    Participant

    Yes, it works with your code! Thanks for your quick reply and help!!

    #1201360
    George
    Participant

    Glad to hear it, @Arno! If you hope to further refine or build upon this code, or troubleshoot issues with it, check out the resources I linked to above for further customization assistance.

    Best of luck with your project in the meantime. 😀

    Cheers,
    George

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Include events in default WordPress search’ is closed to new replies.