Share Now

Following code represents hide a particular post from the main query on Homepage.
All we have to do is just add the POST ID. In this case, it is 99. We have to add this code in functions.php file


function alpha_modify_main_query($wpq){
    if( is_home() && $wpq->is_main_query() ){
        $wpq->set("post__not_in",array(99));
    }
}
add_action( "pre_get_posts","alpha_modify_main_query" );

*** Hide all posts of a particular tag.
If you want to hide all posts of a particular tag then, all we have to do is use


$wpq->set("tag__not_in",array(tag_id));

Picture of Nahid Mahamud

Nahid Mahamud

Web Developer | Graphic Designer | WordPress & Woo-commerce Expert