WordPress.org

Ready to get started?Download WordPress

Forums

Sticky Post in Category (2 posts)

  1. David Jones
    Member
    Posted 4 years ago #

    I have done some extensive searching to get a sticky post to show on top in a category archive and have come close to cracking the nut. But I never got the full solution.

    I have two different categories templates
    1. category-building-science.php
    2. category-social-solutions.php

    And I want the ability to have a sticky post at the top of the category and then just have the rest of the posts flow naturally.

    query_posts(array('post__in'=>get_option('sticky_posts')));

    I know this just returns the sticky post, but how do I get just the rest of the category to follow?

  2. vtxyzzy
    Member
    Posted 4 years ago #

    Use a second loop with this query:

    query_posts(array('post__not_in'=>get_option('sticky_posts')));

    You probably want to include the category selection in both queries so you only get stickies in the category, and then only get the other posts in the category.

Topic Closed

This topic has been closed to new replies.

About this Topic