How can I hide a particular post only from homepage or blogpage

Does anyone know how to hide any particular post from the blog page or homepage. But it should be visible in the category and for everything else.

I found one one plugin but it was last updated 2 years back so.didnot touch, I want it to be done without any plugin
Please if some one know tell me

1 Like

Hide it with CSS
.home .post-1{
display:none;
}

1 Like

Ok so how can I point a partcular post in this css

Whenever I will publish a new post then it will be always hide or it will be assigned with that particular post only.

Replacing 1 with the Post id

If you want to hide in bulk, give these Post a common tag say “hide”
and use CSS

.home .tag-hide{
display:none;
}

or php
function exclude_tag($query) {
if ( $query->is_home() ) {
$query->set( ‘tag’, ‘hide’ );
}
return $query;
}
add_filter( ‘pre_get_posts’, ‘exclude_tag’ );

1 Like

Suppose I have to hide a category from homepage then.
Actually I have a category from which I want to hide all.ppst of it from homepage.

I tried CSS but it did not work.

function exclude_category($query) {
if ( $query->is_home() ) {
$query->set( 'category', 'ID' );
}
return $query;
}
add_filter( 'pre_get_posts', 'exclude_category' );

Edit: Changed curly quote sign to single quote.

2 Likes

Hello @Wasim_Akram This is very easy. if you want to hide on homepage using CSS only

2 Likes
1 Like

@GulshanKumar He want to do t without plugin and without plugin, its very easy

1 Like

@GulshanKumar ALSO The plugin you shared is not updates from a long ago
there’s another plugin but it’s also not updated from long ago

1 Like

I have done it with function. Php code.
It seems very easy

Thanks everyone for that

With plugin, I thought it would be easier and save time.:thinking:

1 Like

I too have few posts which I use to hide in all listing. I have categorized all those posts under a single name.
Then, check your Theme Options and sure you will find an option, “Hide Category”. Select the category which you want to hide and then save it.

1 Like

I have added category excluding code in function. Php and it is working.

1 Like

Please do not press solved button for any random response multiple times, only once for the most satisfactory response.

Ok sir

Thanks for your understanding. I appreciate it.

1 Like