There’s at least 3 ways you can exclude one or more single posts from your home or posts page depending on your Reading Settings.
- You can use CSS code
- You can use PHP code
- You can use a plugin
CSS Code
The easiest way to remove a specific post from your home page is to use CSS code in your child themes srtyle.css file.
.home .post-37401 {
display: none;
}
Simply grab the post i.d from your source code and replace it in the code above.
PHP Code
Another method is to use the posts i.d’s in a custom function in your child themes functions.php file:
add_action( 'pre_get_posts', 'wpsites_remove_posts_from_home_page' );
function wpsites_remove_posts_from_home_page( $query ) {
if( $query->is_main_query() && $query->is_home() ) {
$query->set( 'post__not_in', array( 37401, 37403 ) );
}
}
Simply replace the post i.d’s in the code above with your own.
Plugin
If you looking for a non coding option, there’s several plugins which get the job done, one of which is Simple Exclude.
Hi Brad
Good to see you are working through the holiday and thanks for more useful tips and coding.
My pleasure Keith. Thanks for all your comments.