• Hi, i tried getting the sticky posts before the loop like this:

    <?php
        /* Get all sticky posts */
        $sticky = get_option( 'sticky_posts' );
    
        /* Sort the stickies with the newest ones at the top */
        rsort( $sticky );
    
        /* Get the 5 newest stickies (change 5 for a different number) */
        $sticky = array_slice( $sticky, 0, 5 );
    
        /* Query sticky posts */
        query_posts( array( 'post__in' => $sticky, 'caller_get_posts' => 1 ) );
        ?>

    But when I do so the main loop is empty and no other posts are displayed.

    Any ideas?

    Thanks in advance,
    Jogol

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter jogol

    (@jogol)

    I want to add that I´m trying this on the Twenty Ten 1.1 template, in loop.php.

    Thanks!

    Hi there!

    You might forgot one important instruction before displaying the sticky posts:

    wp_reset_query();

    Let me know if that solves the problem!

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

The topic ‘get sticky posts outisde the loop’ is closed to new replies.