-
AuthorPosts
-
June 28, 2022 at 9:39 am #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.
June 28, 2022 at 11:39 am #1356705well 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' );
June 29, 2022 at 11:00 am #1356826i 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’ );July 2, 2022 at 5:43 am #1357030Hi 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,
NikkoJuly 2, 2022 at 8:10 am #1357040maybe 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 );
July 2, 2022 at 2:31 pm #1357075Hi 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,
NikkoJuly 3, 2022 at 6:16 pm #1357143The 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 )July 3, 2022 at 7:10 pm #1357147 -
AuthorPosts
- You must be logged in to reply to this topic.