Support » Plugin: The Events Calendar » How to remove “Hide From Event Listings” from the main search
How to remove “Hide From Event Listings” from the main search
-
Hi there,
How can I remove “Hide From Event Listings” from the WP main search ?
Thank you
-
I try to do something like this but is not working.
function aet_exclude_from_search( $query ) { if ( $query->is_search ) { $query->set( 'post_type', array( 'page', 'post', 'blog', 'tribe_events' ) ); $query->set('meta_query', array( array( 'key' => 'EventHideFromUpcoming', 'value' => '0' ) ) ); } return $query; } add_action( 'pre_get_posts','aet_exclude_from_search' );
-
This reply was modified 3 months, 1 week ago by
Nuno Sarmento.
Thanks for reaching out!
Are you looking to remove your events from the main WP search or are you looking to include them in the search and remove them from the event listings on your site?
Once I have some clarification here, I’d be happy to assist!
Thanks,
JaimeI am looking to remove all “Hide from event listings” events from the main WordPress search.
Thank you.
-
This reply was modified 3 months, 1 week ago by
Nuno Sarmento.
Thanks for the clarification.
Unfortunately, customizations are beyond the scope of support that we provide, as per our support policy.
With that being said, we’d be happy to point you in the right direction.
You can try modifying the snippet provided in the following forum thread:
https://wordpress.org/support/topic/hide-past-events-in-the-main-wordpress-search/I hope that helps!
Thanks,
JaimeThank you for your fast response.
This is not an extra customisations, it is a bug.
I assume if the “Hide from event listings” metabox option is ticked it will remove the events from any search query otherwise whats the point to have a “Hide events” if the events can be found in the WordPress search results.
Thank you for the above links but the requests are completely different they are not related.
Nuno
Thanks for your response! The “Hide from event listings” setting will only remove the events from the main calendar views like Month View and List View. It will still be searchable by default in the WordPress search and will still be accessible as a single event URL.
If you’d like to customize this, you could try excluding eventsbased on the custom meta. This has some examples: https://wordpress.stackexchange.com/questions/334194/exclude-posts-with-specific-metadata-from-search
You would have to target the search query at pre get posts, that link does not show how to do that.
I hope that helps!
Thanks,
JaimeHey there! This thread has been inactive for a while so we’re going to go ahead and mark it Resolved. Please feel free to open a new thread if any other questions come up and we’d be happy to help. 🙂
-
This reply was modified 3 months, 1 week ago by
- You must be logged in to reply to this topic.