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

WP SITES

2784

Original Genesis Tutorials & 6000+ Guaranteed Code

Snippets

  • Consultation
  • Full Access
  • Log in

Exclude Latest Post From Home Page Loop

In this tutorial. i’ll provide the code i tested which excludes the latest published post from your home page loop.

Simply copy this PHP from the view raw link in the Gist and paste it at the end of your child themes functions.php file using a code editor.

The code above simply removes your most recent published post from the home page loop and can also be easily modified to offset any number of posts from the posts page you select in your Reading settings.

The home page loop may also be called your posts page or blog page.

When you publish a new post, it will be removed from the loop until you publish another post.

Similar Tutorials & Code Snippets

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

pre_get_posts

Reader Interactions

Comments

  1. Steck says

    November 5, 2014 at 6:12 pm

    Thanks Brad! I wish I had seen this post earlier!

    This code for offsetting posts is quite similar to what I discovered as well. If you or your readers are interested in adding a bit of additional code, you can configured the site to maintain pagination as well.

    Here is the additional code:

    add_filter('found_posts', 'myprefix_adjust_offset_pagination', 1, 2 );
    function myprefix_adjust_offset_pagination($found_posts, $query) {
    
        //Define our offset again...
        $offset = 1;
    
        if ( $query->is_posts_page ) {
            return $found_posts - $offset;
        }
        return $found_posts;
    }

    For an extended explanation of this code visit this tutorial: “How to offset posts in the Genesis framework without losing pagination”.

    Log in to Reply
    • Brad Dalton says

      November 5, 2014 at 6:38 pm

      Thanks Steck

      Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags