• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2665

Original Genesis Tutorials & 5000+ Guaranteed Code

Snippets

  • Support
  • Newsletter
  • Videos
  • Log in

Premium Member? - Request custom code

3 Ways To Remove or Exclude Posts From Your Home Page Loop

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.

  1. You can use CSS code
  2. You can use PHP code
  3. 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.

Related Solutions

  • 5 Ways To Exclude Posts In Specific Categories From Displaying
  • Exclude Latest Post From WordPress Home Page Loop

pre_get_posts

Reader Interactions

Comments

  1. Keith Davis says

    December 27, 2013 at 5:43 pm

    Hi Brad
    Good to see you are working through the holiday and thanks for more useful tips and coding.

    Log in to Reply
    • Brad Dalton says

      December 27, 2013 at 6:13 pm

      My pleasure Keith. Thanks for all your comments.

      Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

PHP Code

template_include

get_body_class

if else

array

class_exists

foreach

sprintf

add_action

printf

variable

Advertise · WPEngine · Genesis · Log in

  • How Premium Membership Works
  • Sign Up
  • Support
  • Subscription Details/Invoice
  • Tagged Tutorials
  • Access-Download Problems