I have a wordpress archives page that is displaying a custom post type that I've created that I actually want hidden.
I used the plugin, CPT UI, to create the post type "Event"
On my blog, I have a category labeled Featured (website.com/category/featured/), and on this Featured category page I have a few Event CPT's showing up that I want to not be displaying.
I've tried the following code within my functions.php file that did not work:
add_action( 'pre_get_posts', 'exclude_cpt' );
function exclude_cpt( $query ) {
if ( $query->is_category('featured') ) {
$query->set( 'post_type', array('event') );
}
return $query;
}
Thoughts??