Title: Sticky posts not &#8220;sticking&#8221; when using query_posts()
Last modified: August 19, 2016

---

# Sticky posts not “sticking” when using query_posts()

 *  Resolved [DaveE](https://wordpress.org/support/users/dpe415/)
 * (@dpe415)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/sticky-posts-not-sticking-when-using-query_posts/)
 * Hello,
 * Maybe I’m completely misunderstanding something about the sticky posts functionality,
   but for the life of me I can’t get sticky posts to float up/stick to the top 
   when I query posts by category before the loop. I’ve looked through all the sticky
   post documentation/posts and don’t understand what I’m doing wrong.
 * For example, in my blog homepage (index.php) I’ve added `query_posts('category_name
   =news');` just before the main loop. I have a post mapped to the news category
   and also set to sticky. When viewing the site homepage the post doesn’t stick
   to the top; instead it shows up in the proper chronological order further down
   the page. If I remove the `query_posts` call, the post sticks correctly, but 
   the loop also shows a bunch of non “news” posts that I don’t want to display.
 * My goal for the blog homepage is to only show posts from the News category and
   make sure any sticky posts in the News category are stuck to the top of the homepage(
   as well as the related category page).
 * Am try to do something that isn’t possible in one loop? Is there a better way
   to accomplish my goal?
 * Thanks for the help!
 * DaveE

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [kz](https://wordpress.org/support/users/kz/)
 * (@kz)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/sticky-posts-not-sticking-when-using-query_posts/#post-1359547)
 *     ```
       $sticky = get_option('sticky_posts');
       query_posts(array(
         'post__in' => $sticky,
         'category_name' => 'news'
       ));
   
       /* The loop for sticky here. */
   
       query_posts(array(
         'post__not_in' => $sticky;
         'category_name' => 'news'
       ));
   
       /* The loop for news category without sticky here. */
   
       wp_reset_query();
       ```
   
 *  Thread Starter [DaveE](https://wordpress.org/support/users/dpe415/)
 * (@dpe415)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/sticky-posts-not-sticking-when-using-query_posts/#post-1359866)
 * Thanks for the feedback. Your suggestion worked perfectly. Just out of curiosity,
   why does using the `query_posts()` object kill the “standard” method of displaying
   sticky posts at the top? Wouldn’t the sticky posts option/functionality be part
   of the default `query_posts()` query?
 * Thanks again,
 * DaveE

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Sticky posts not “sticking” when using query_posts()’ is closed to new
replies.

## Tags

 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)
 * [Sticky posts](https://wordpress.org/support/topic-tag/sticky-posts/)

 * 2 replies
 * 2 participants
 * Last reply from: [DaveE](https://wordpress.org/support/users/dpe415/)
 * Last activity: [16 years, 3 months ago](https://wordpress.org/support/topic/sticky-posts-not-sticking-when-using-query_posts/#post-1359866)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
