WordPress.org

Support

Support » Plugins and Hacks » Exclude latest post from loop with $query->set

Exclude latest post from loop with $query->set

  • Ian Stewart

    @iandstewart

    Theme Wrangler

    Can one exclude the latest post from the loop using “$query->set”? I’d like to do something along the following lines:

    function excludelatestpost($query) {
    if ($query->is_home) {
    $query->set('this would be the tricky bit');
    }
    return $query;
    }
    add_filter('pre_get_posts','excludelatestpost');

    Any clues?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude latest post from loop with $query->set’ is closed to new replies.