Search for the Article

How to Hide Post from Home Page and Blog Page in Wordpress

Step by Step Procedure to hide post from home page

Step 1: Identify the Post ID
First you need to get the post ID which you want to hide on home page.

Wordpress Post ID for Hiding Post on Home Page
Wordpress Post ID


Step 2: Edit Your Function.php file
Open your function.php file and paste the below mention code in it.



<?php
function wpb_exclude_from_home($query) {
      if ($query->is_home() ) {
          $query->set('post__not_in', array(xx));
      }
}
add_action('pre_get_posts', 'wpb_exclude_from_home');
?>



Replace the Array "XX" with your Post "ID". and then save it. In my case it is "1044".


Wordpress Post function.php for Hiding Post on Home Page
Wordpress function.php file


Step 3: Its Done !!

Check your home page or blog page, it iw now disappear from home page and blog page. If it is still showing their please let me know in comments.