Site logo

Archived topic

Java Theme - Hide Post Category

5 replies · Started by bearbully on September 20, 2021

Viewing posts 1–6 of 6

Hi, I’m currently using Java theme, how can I hide a specific category from Blog page ? Thank you

Hi there,

I'm not exactly sure I fully understand what you mean.

To clarify, do you want to hide the "category" meta or perhaps you want to remove posts under a specific category from the Blog index page?

Let us know.

Hi, I hope to hide blog posts for a specific category (e.g hidden), while showing blog posts for other category (e.g food, drinks)

You'll need to do a pre_get_posts filter for that. :)

Example: excluding posts from category w/ ID of 1.

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

thank you

No problem. :D

This archived topic is closed to new replies.