Exclude categories when dropdown filter active
-
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?!
- The topic ‘Exclude categories when dropdown filter active’ is closed to new replies.