Title: Sticky posts doesn&#8217;t work on query_posts?
Last modified: August 19, 2016

---

# Sticky posts doesn’t work on query_posts?

 *  Resolved [akis](https://wordpress.org/support/users/akis/)
 * (@akis)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/sticky-posts-doesnt-work-on-query_posts/)
 * I have the following code:
 *     ```
       <?php
       $sixt_id = get_catId("Blog");
       $sixt_id .= ",".get_catId("Featured");
       $sixt_id .= ",".get_catId("Premium");
   
       query_posts("showposts=6&cat=".$sixt_id);
       if (have_posts()) : while (have_posts()) : the_post();
   
       echo get_the_title();
   
       endwhile;
       endif;
       ?>
       ```
   
 * On featured category I have a sticky post, but doesn’t show up in front, why?

Viewing 15 replies - 1 through 15 (of 21 total)

1 [2](https://wordpress.org/support/topic/sticky-posts-doesnt-work-on-query_posts/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/sticky-posts-doesnt-work-on-query_posts/page/2/?output_format=md)

 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/sticky-posts-doesnt-work-on-query_posts/#post-1564472)
 * See the sticky parameters.
    [http://codex.wordpress.org/Function_Reference/query_posts#Sticky_Post_Parameters](http://codex.wordpress.org/Function_Reference/query_posts#Sticky_Post_Parameters)
 *  Thread Starter [akis](https://wordpress.org/support/users/akis/)
 * (@akis)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/sticky-posts-doesnt-work-on-query_posts/#post-1564480)
 * Thanks. I have checked those but didn’t help, I don’t want to display only sticky
   posts, I just want the normal behavior.
 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/sticky-posts-doesnt-work-on-query_posts/#post-1564485)
 * Stickies should already be included in the query, unless they’re not matched 
   against the parameters you’ve set, ie. within the categories above (blog, featured,
   premium).
 *  Thread Starter [akis](https://wordpress.org/support/users/akis/)
 * (@akis)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/sticky-posts-doesnt-work-on-query_posts/#post-1564491)
 * They are included but like normal posts not stickies.
 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/sticky-posts-doesnt-work-on-query_posts/#post-1564493)
 * Try setting the `caller_get_posts` parameter (try both values, 1 and 0, should
   only take a minute).
 *  Thread Starter [akis](https://wordpress.org/support/users/akis/)
 * (@akis)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/sticky-posts-doesnt-work-on-query_posts/#post-1564497)
 * Tried that already, nothing changed.
 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/sticky-posts-doesnt-work-on-query_posts/#post-1564499)
 * I have no idea why they’re not retaining the order, if you remove the query posts
   line do stickies then behave correctly? (simply to test).
 *  Thread Starter [akis](https://wordpress.org/support/users/akis/)
 * (@akis)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/sticky-posts-doesnt-work-on-query_posts/#post-1564500)
 * Yes, but unfortunately this is not a solution.
 * Some related question:
    Do you have any idea if its possible to prioritize posts
   from Featured category?
 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/sticky-posts-doesnt-work-on-query_posts/#post-1564506)
 * Was never intended to be a solution, simply a test to see if the problem is still
   apparent.
 * Query posts should work with stickies if caller_get_posts is set accordingly,
   but i do remember a thread from a while back that i answered where another user
   had the same problem, i’ll see if i can dig it up.. (will edit post if i can 
   find it).
 * **EDIT:** _Here’s the thread i mentioned which contains a work-around for the
   problem._
    [http://wordpress.org/support/topic/309252](http://wordpress.org/support/topic/309252)
 * Not sure what you mean on your related question, can you elaborate please?
 *  Thread Starter [akis](https://wordpress.org/support/users/akis/)
 * (@akis)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/sticky-posts-doesnt-work-on-query_posts/#post-1564508)
 * My code displays last six posts from those 3 categories.
    If possible, I want
   to show posts from Featured category first. Featured may contain posts from Blog
   and other categories.
 *  Thread Starter [akis](https://wordpress.org/support/users/akis/)
 * (@akis)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/sticky-posts-doesnt-work-on-query_posts/#post-1564520)
 * It seems that using this query, sticky posts are displayed fine but the showposts
   count no longer works, it displays 6 normal posts + x sticky posts. Do you have
   any ideea why?
 *     ```
       <?php
       query_posts("showposts=6&".array('category__in' => array($sixt_id)));
       ?>
       ```
   
 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/sticky-posts-doesnt-work-on-query_posts/#post-1564522)
 * You can’t combine a string and an array, either use an array or a string for 
   the parameters.
 * Try this..
 *     ```
       query_posts( array( 'posts_per_page' => 6, 'category__in' => array( $sixt_id ) ) );
       ```
   
 * **NOTE:** Changed to `posts_per_page` as `showposts` is deprecated, however showposts
   does still work(currently), simply showing you the new way… 🙂
 *  Thread Starter [akis](https://wordpress.org/support/users/akis/)
 * (@akis)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/sticky-posts-doesnt-work-on-query_posts/#post-1564526)
 * For some reason now it displays posts only from the first category (Blog).
 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/sticky-posts-doesnt-work-on-query_posts/#post-1564538)
 * You variable is not an array, it’s a string.. (i missed that before).
 * Change this.
 *     ```
       $sixt_id = get_catId("Blog");
       $sixt_id .= ",".get_catId("Featured");
       $sixt_id .= ",".get_catId("Premium");
       ```
   
 * to…
 *     ```
       $sixt_id = array( get_catId("Blog"), get_catId("Featured"), get_catId("Premium") );
       ```
   
 * ..and as the variable is now an array, change this..
 *     ```
       query_posts( array( 'posts_per_page' => 6, 'category__in' => array( $sixt_id ) ) );
       ```
   
 * to..
 *     ```
       query_posts( array( 'posts_per_page' => 6, 'category__in' => $sixt_id ) );
       ```
   
 * Or, just do this..
 *     ```
       query_posts( array( 'posts_per_page' => 6, 'category__in' => array( get_catId("Blog"), get_catId("Featured"), get_catId("Premium") ) ) );
       ```
   
 *  Thread Starter [akis](https://wordpress.org/support/users/akis/)
 * (@akis)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/sticky-posts-doesnt-work-on-query_posts/#post-1564663)
 * Sorry for the delay, still doesn’t work.
    Using an array for posts_per_page seems
   to disable the sticky behaviour.
 * What I really want:
    – I’m showing six posts from Blog category on homepage (
   ordered by date) – Here, I want to promote (give priority) to some old posts (
   from the Blog category)
 * Any ideea how to achieve this?

Viewing 15 replies - 1 through 15 (of 21 total)

1 [2](https://wordpress.org/support/topic/sticky-posts-doesnt-work-on-query_posts/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/sticky-posts-doesnt-work-on-query_posts/page/2/?output_format=md)

The topic ‘Sticky posts doesn’t work on query_posts?’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 21 replies
 * 3 participants
 * Last reply from: [carl-johan](https://wordpress.org/support/users/carl-johan/)
 * Last activity: [15 years, 7 months ago](https://wordpress.org/support/topic/sticky-posts-doesnt-work-on-query_posts/page/2/#post-1564861)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
