WordPress.org

Ready to get started?Download WordPress

Forums

Exclude latest post from loop with $query->set (3 posts)

  1. Ian Stewart
    Theme Wrangler
    Posted 5 years ago #

    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?

  2. jesseisrad
    Member
    Posted 4 years ago #

    What do you mean by "latest posts"

    Seems like query->set uses query db fields so...

  3. jesseisrad
    Member
    Posted 4 years ago #

    such as the parameters discussed here:

    http://codex.wordpress.org/Template_Tags/query_posts

    maybe for "latests" you want the timed-parameters:

    http://codex.wordpress.org/Template_Tags/query_posts#Time_Parameters

    hope that helps.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags