The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Multiple loops and sticky posts (5 posts)

  1. Cedric
    Posted 6 years ago #


    I have two loops in a page of my custom theme. For each loop, I use the WP_Query function.

    The first loop displays all the posts from all the categories, and when there are sticky posts, they come on the top of the list. That's normal.

    The second loop displays four posts from one category only (like a featured category). But when there are sticky posts in this category, i'd like to see them on the top of this section. But currently, they just appears in their normal order (by date).

    This is the code of my second loop:

    $args = array('cat' => 3, 'posts_per_page' => 4, 'post_status' => 'publish' );
    $highlights = new WP_Query($args);?>
    <?php while ( $highlights->have_posts() ) : $highlights->the_post() ; ?>
    <!-- title, content, image, etc. -->
    <?php endwhile; ?>

    Does anyone know how to force the sticky posts to appear first?

    Any help would be greatly appreciated!


  2. childheart82
    Posted 6 years ago #

    Same issue here... can anyone help us?

  3. vtxyzzy
    Posted 6 years ago #

    See if adding 'caller_get_posts=0' to the arguments will help.

    $args = array('cat' => 3, 'posts_per_page' => 4, 'post_status' => 'publish', 'caller_get_posts' => 0 );

  4. childheart82
    Posted 6 years ago #

    Thank you vtxyzzy!
    I added calleg_get_posts to my args as follows:
    $args = array(
    'posts_per_page' => 5,
    'post_status' => 'publish',
    but still sticky posts don't show at the top.. :°°

  5. vtxyzzy
    Posted 6 years ago #

    I wonder if something in your theme, or in a plugin might be interfering. Try switching to the default theme to see if the problem goes away. If not, try disabling all plugins.

Topic Closed

This topic has been closed to new replies.

About this Topic