Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1356684

    Hi

    Is there any way to not display / search ANYTHING from Events Calendar in Enfold Search?

    We don’t want a search to fetch anything from The Events Calendar plugin…

    Hope you can help.

    #1356705

    well to include a custom-post-type to search results this is the snippet:

    function include_custom_search( $query ) {
        if ( $query->is_search ) {
        $query->set( 'post_type', array( 'post', 'page', 'custom_post_type' ) );
        }  
        return $query;
    }
    add_filter( 'pre_get_posts', 'include_custom_search' ); 

    maybe it works the other way too :

    function exclude_from_search($query) {
      if ( !$query->is_admin && $query->is_search) {
        $query->set('post_type', array('page','post') );
      }
      return $query;
    }
    add_filter( 'pre_get_posts', 'exclude_from_search' );
    #1356826

    i found here some hooks for tribe-events: https://docs.theeventscalendar.com/reference/classes/tribe-events-views-v2-hooks/
    but I did not investigate the matter more deeply due to lack of time. ( so try first the last snippet)
    maybe that filter is the one you need: add_filter( ‘tribe_suppress_query_filters’, ‘__return_true’ );

    #1357030

    Hi whdsolutions,

    Please try the custom code suggested by @Guenni007 (it does work properly), you’ll just need to add some custom post types that you want to include in the search.


    @Guenni007
    thanks for helping out.

    Best regards,
    Nikko

    #1357040

    maybe this is better – because even pages with tribe-events ( pages with tribe lists ) are not in the search:
    (i hope so – i can not test it – lack of using Events Calendar)

    function exclude_tribe_events() {
        global $wp_post_types;
        if ( post_type_exists( 'tribe_events' ) ) {
            $wp_post_types['tribe_events']->exclude_from_search = true;
        }
    }
    add_action( 'init', 'exclude_tribe_events', 99 );
    #1357075

    Hi Guenni007,

    I have tested your code and it does work properly.
    I don’t see any significant difference between the two codes in terms of functionality, so I think both whdsolutions can use one or the other, the latter would be more preferrable since you don’t need to modify anything on the code :)

    Best regards,
    Nikko

    #1357143

    The last code snippet explicitly excludes the Tribe Events, the last but one excludes the tribe events (but also other Custom Post Types (CPTs)) by not naming them in the arrays.

    _____
    :)
    All may come to the party except Guenni007 ( number of guests any number)
    Jill and Jack are allowed to come to the party. ( yes Guenni007 is not allowed to come – but neither are the rest – number of guests : 2 )

    #1357147

    Hi,
    Guenni007 thank you for sharing and explaining.

    Best regards,
    Mike

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.