Way to show only certain categories on the blog page

I wanted to have my main blog page, show all catagories but hide press releaess? is there a way to do that?

Hi @designbabe,

Thanks for reaching out.

It’s possible, please add this code to your child theme’s functions.php along with the ID of the press release category.

function exclude_this_category( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'cat', '-565' );
}
}
add_action( 'pre_get_posts', 'exclude_this_category' );

And please check this on how you can find the category ID https://theme.co/apex/forum/t/setup-how-to-locate-category-ids/60

If your category ID is 783, then the set query should be like this $query->set( 'cat', '-783' ); (with negative).

Thanks!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.