Hi,
Do you want to exclude the categories from the Recent Posts Section? If that so, It’s not a widget, It’s a WP main content section. You can’t exclude the cat ID in the main loop, instead of that you have to create custom queries to achieve the desired result.
You can get the sample query in page-blog.php in our theme. In that query, you have to pass the cat=-12
here -12 is your category ID.
or easy way, include the following code in functions.php and add the category ID to be excluded.
function tp_exclude_category( $wp_query ) {
// Add the category to an array of excluded categories. Here, We pass the -1 as a category ID,
$excluded = array( '-1' );
// Note that this is a cleaner way to write: $wp_query->set('category__not_in', $excluded);
set_query_var( 'category__not_in', $excluded );
}
add_action( 'pre_get_posts', 'tp_exclude_category' );
I think, i got your question. If that doesn’t solve your question, reply to us.
Thank you.