WordPress.org

Support

Support » How-To and Troubleshooting » Sticky Post in Category

Sticky Post in Category

  • 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?

Viewing 1 replies (of 1 total)
  • 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.

Viewing 1 replies (of 1 total)
  • The topic ‘Sticky Post in Category’ is closed to new replies.
Skip to toolbar