Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 512573

Exclude categories when dropdown filter active

$
0
0

Replies: 0

OK, so I have used this function to exclude category 27 from the dropdown – awesome so far!

function em_wpfullcalendar_category_label($taxonomy_args,$taxonomy){
 if ( $taxonomy->name == 'event-categories'){
  $taxonomy_args['exclude'] = '27';
 }
 return $taxonomy_args;
}
add_filter('wpmfc_calendar_taxonomy_args','em_wpfullcalendar_category_label',1,2);

On page id 54, I am hiding category 27 completely by using the shortcode : [fullcalendar category=”-27″]

However, my items in category 27 are also in the categories used by the dropdown filter. So say for instance I have an item in multiple categories, e.g. cat 27 and cat 2. If I select cat 2 from the dropdown filter it will shows items in cat 2 and in cat 27 and ignore the exclusion in the shortcode.

I tried this function:

function exclude_category($query) {
if ( $query->is_page( '54' ) ) {
$query->set('event-categories', '-27');
}
return $query;
}
add_filter('pre_get_posts', 'exclude_category');

But no luck.

Any suggestions anyone?!


Viewing all articles
Browse latest Browse all 512573

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>