Title: WP_Query with sticky posts
Last modified: August 22, 2016

---

# WP_Query with sticky posts

 *  [mxpimp47](https://wordpress.org/support/users/mxpimp47/)
 * (@mxpimp47)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/wp_query-with-sticky-posts/)
 * I have a custom WP_Query and wanted to have sticky posts show up top. I got that
   happening by reading the docs, and putting something together. But not sure if
   its a correct way to do it.
 * But also is it normal to show the sticky posts on the same page in the default
   order below “x” amount of posts? It looks kind of funny if there is a sticky 
   post up top then 3 posts down you see it in the correct order. I couldn’t figure
   out how to hide that if thats normal practice.
 * Here is my code – [http://pastebin.com/p2atVa2p](http://pastebin.com/p2atVa2p)

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

 *  [danielfonda](https://wordpress.org/support/users/danielfonda/)
 * (@danielfonda)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/wp_query-with-sticky-posts/#post-5678192)
 * It’s simple really.
 * 1st query: only sticky posts
    reset query 2nd query (add a rule sticky=false)
 * I trust you should be able to write the actual code for it.
 * Hope this helps, lemme know how it goes 🙂
 *  Thread Starter [mxpimp47](https://wordpress.org/support/users/mxpimp47/)
 * (@mxpimp47)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/wp_query-with-sticky-posts/#post-5678255)
 * Would a conditional statement be better instead of two query’s?
 *  [danielfonda](https://wordpress.org/support/users/danielfonda/)
 * (@danielfonda)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/wp_query-with-sticky-posts/#post-5678258)
 * Honestly I think it’s a lot easier and cleaner with two queries.
 *  Thread Starter [mxpimp47](https://wordpress.org/support/users/mxpimp47/)
 * (@mxpimp47)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/wp_query-with-sticky-posts/#post-5678304)
 * I have made two queries like you suggested. One problem I have is I was using
   php count to insert a clearfix div for responsive purposes. Now with two queries
   its obviously not going to work correctly. Any suggestions on handling this?
 * [http://pastebin.com/CV3mS73r](http://pastebin.com/CV3mS73r)

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

The topic ‘WP_Query with sticky posts’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [mxpimp47](https://wordpress.org/support/users/mxpimp47/)
 * Last activity: [11 years, 5 months ago](https://wordpress.org/support/topic/wp_query-with-sticky-posts/#post-5678304)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
