Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Exclude one event category from main post loop WordPress



[Plugin: The Event Calendar]
[Theme: Vantage]

I'm using The Event Calendar plugin. I've created two categories (HIDDEN and NEWS) within it.
All events are added to my main blog-loop, but I don't want the HIDDEN category to show up.

How do I do this?

Best regards,

Answers (2)


Hariprasad Vijayan answers:

Hello MadsRH,

Try this on your functions.php,
add_action( 'pre_get_posts', 'home_exclude_events_category' );
function home_exclude_events_category( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'tax_query', array(
'taxonomy' => TribeEvents::TAXONOMY,
'field' => 'slug',
'terms' => array( 'hidden'),
'operator' => 'NOT IN'
) );

return $query;


Mads R.H. comments:

Hariprasad -> Perfect! Thank you!

Can I use the same category name (hidden) for my regular posts, if I would want to hide one of them too?


Navjot Singh answers:

You can try something like this: [[LINK href=""]][[/LINK]]

Mads R.H. comments:

Navjot Singh -> This removes the categories from the widget, but not from the blog-loop