Title: peeves6's Replies | WordPress.org

---

# peeves6

  [  ](https://wordpress.org/support/users/peeves6/)

 *   [Profile](https://wordpress.org/support/users/peeves6/)
 *   [Topics Started](https://wordpress.org/support/users/peeves6/topics/)
 *   [Replies Created](https://wordpress.org/support/users/peeves6/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/peeves6/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/peeves6/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/peeves6/engagements/)
 *   [Favorites](https://wordpress.org/support/users/peeves6/favorites/)

 Search replies:

## Forum Replies Created

Viewing 1 replies (of 1 total)

 *   Forum: [Themes and Templates](https://wordpress.org/support/forum/themes-and-templates/)
   
   In reply to: [Suburbia theme – sticky post problem](https://wordpress.org/support/topic/suburbia-theme-sticky-post-problem/)
 *  [peeves6](https://wordpress.org/support/users/peeves6/)
 * (@peeves6)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/suburbia-theme-sticky-post-problem/#post-3009720)
 * There is another way of manipulating the sticky posts within Suburbia theme.
 * This is by using the function is_sticky($post->ID)
 * As per WordPress Codex, query_posts is not efficient or recommended. The SQL 
   query fetching yours posts has already been performed when home.php is displayed.
 * So remove the query_posts call, use the while loop and add the if statement to
   check if post is sticky or not. Run the while loop twice, once for displayed 
   sticky posts and a second time for displaying non sticky posts.
 * <!– LOOP1 Sticky Posts –>
    <?php if (have_posts()) : ?> <?php while (have_posts()):
   the_post(); ?>
 *  <!– Check if sticky post –>
    <?php if (is_sticky($post->ID)) : ?> //leave the
   post two display code as is
 * <?php else : ?>
    <?php endif; ?> <?php endwhile; ?> <?php else : ?> <?php endif;?
   >
 * then,
    <!– LOOP2 Non sticky posts –> <?php if (have_posts()) : ?> <?php while(
   have_posts()) : the_post(); ?>
 *  <!– Check if not a sticky post –>
    <?php if (!is_sticky($post->ID)) : ?>
 * Remove call to query_posts and also reset query.
    Add to above any extra code
   to display only x number of sticky or non sticky posts on the page.
 * The advantage is that with query_posts you are making two extra DB calls, once
   to retrieve sticky posts and another time to retrieve non sticky posts. With 
   the above, you dont have that anymore.
 * It seems to work for me…

Viewing 1 replies (of 1 total)