WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Omitting one post with pagination (5 posts)

  1. aparentdesign
    Member
    Posted 4 years ago #

    Hi there, I have a featured post on the home page, and would like it not to show up on other pages. HOWEVER, I don't want to omit its category since older posts in that category should be viewable.

    I have got this working with multiple loops, however the pagination is off. The page where it skips the featured post only has 9 other posts. I am trying to make a new query to omit that post, but there doesn't seem to be parameter to do so.

    $wp_query->query('p=-' . $featuredPostID . '&paged='.$paged);

    =- doesn't work for this attribute as it does for cat= - to omit categories.

    How can I do this?

  2. MichaelH
    Member
    Posted 4 years ago #

    Since you started this topic, please note I deleted your comment on that old thread http://wordpress.org/support/topic/308234

  3. aparentdesign
    Member
    Posted 4 years ago #

    Thanks. I changed my mind and decided this would be more direct. Any ideas?

  4. MichaelH
    Member
    Posted 4 years ago #

    Could use the post__not_in argument. See query_posts().

  5. aparentdesign
    Member
    Posted 4 years ago #

    Thanks. It seems more complicated than necessary, but this worked:

    $args = array(
    'post__not_in' => array($featuredPostID),
    'paged' => $paged
    );

    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query($args);

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags