Hello
Is it possible to exclude certain categories from being returned in the search function?
Also, is it possible to prevent certain categories from showing in the category dropdown for the search funtion.
I’ve tried listing them by slug, but those not listed are appearing in the drop-down.
[event_search event_start_after=”now” posts_per_page=”8″ event-category=”music,adult-outreach,education,exhibition,featured,family,other-events,special-services” filters=”date,event_category”]
Here is the page: http://minster.southwellminster.org/event-search/
Many thanks for your help, I’m finding it a very useful plugin.
Best wishes
Madeleine
Madeleine Parkyn
Hi
I’d really appreciate some guidance with the query above about excluding certain categories from the displayed search results.
Many thanks
Madeleine
Madeleine Parkyn
Hi Madeleine,
There isn’t an option to do this, so you would have to modify the code base directly. In line of 203 of includes/shortcodes.php, there is:
$tax = get_taxonomy( 'event-venue' );
$venue_objs = eo_get_venues();
if ( $venue_objs ) {
...
You can modify the $venue_objs
objecto filter out any venues you don’t want:
$tax = get_taxonomy( 'event-venue' );
$venue_objs = eo_get_venues();
$venue_objs = array_filter($venue_objs, function($venue) {
$whitelist = array('music', 'adult-outreach', 'education');
return in_array($venue->slug, $whitelist);
});
if ( $venue_objs ) {
...
Stephen Harris
Many thanks Stephen. I’ll give it a go.
With best wishes
Madeleine
Madeleine Parkyn
Hi Stephen
I’m a bit confused. I asked about catgories, but your reply refers to venues, with category slugs?
Many thanks
Madeleine
Madeleine Parkyn
Sorry, for categories line 321 has
$taxonomy = get_taxonomy( $filter );
$term_objs = get_terms( $taxonomy->name, array( 'hide_empty' => 0 ) );
You can modify that to:
$taxonomy = get_taxonomy( $filter );
$term_objs = get_terms( $taxonomy->name, array( 'hide_empty' => 0 ) );
if('event-category' === $filter){
$term_objs = array_filter($term_objs, function($term) {
$whitelist = array('music', 'adult-outreach', 'education');
return in_array($term->slug, $whitelist);
});
}
Stephen Harris
Hi Stephen
I’m not seeing that at line 321 of includes/shortcodes.php.
From line 203 I’m seeing
$tax = get_taxonomy( 'event-category' );
$cat_objs = get_terms( 'event-category', array( 'hide_empty' => 0 ) );
if ( $cat_objs ) {
$cats = array_combine( wp_list_pluck( $cat_objs, 'slug' ), wp_list_pluck( $cat_objs, 'name' ) );
} else {
$cats = array();
What should I be changing?
Many thanks for your help
Madeleine
Madeleine Parkyn
What version of Event Organiser Pro are you running?
Stephen Harris
Hi Stephen
It’s Version 1.11.15 for Event Organiser Pro
and
Version 3.7.4 for Evetn Organiser
Thanks for following up on this.
Best wishes
Madeleine
Madeleine Parkyn
Hi Stephen
I was wondering if you’d had any further thoughts about this?
Many thanks
Madeleine
Madeleine Parkyn
In that case, please try:
case 'event_category':
$tax = get_taxonomy( 'event-category' );
$cat_objs = get_terms( 'event-category', array( 'hide_empty' => 0 ) );
$cat_objs = array_filter($cat_objs, function($cat) {
$whitelist = array('music', 'adult-outreach', 'education');
return in_array($cat->slug, $whitelist);
});
if ( $cat_objs ) {
$cats = array_combine( wp_list_pluck( $cat_objs, 'slug' ), wp_list_pluck( $cat_objs, 'name' ) );
} else {
$cats = array();
}
(note the added four lines).
$cat_objs = array_filter($cat_objs, function($cat) {
$whitelist = array('music', 'adult-outreach', 'education');
return in_array($cat->slug, $whitelist);
});
Stephen Harris
Thanks very much Stephen. That has done the trick, now I can choose which categories display on the drop down.
Thank you for your help. Have a good weekend.
Madeleine
Madeleine Parkyn