Display only the most recent sticky post, display other posts in chronological order

I want to display only the most recent sticky post at the top of the TwentyEleven page, and display the rest of the posts in chronological order, no matter whether they are sticky or not.

I tried to find. solution here:

http://codex.wordpress.org/Sticky_Posts

But it doesn’t seem to have what I need. Could someone please help to formulate the correct statement? Thank you!

1 Answer
1

That page has exactly what you need:

Display just the first sticky post, if none return nothing:

$sticky = get_option( 'sticky_posts' );
$args = array(
    'posts_per_page' => 1,
    'post__in'  => $sticky,
    'ignore_sticky_posts' => 1
);
query_posts( $args );
if ( $sticky[0] ) {
    // insert here your stuff...
}

Source: http://codex.wordpress.org/Sticky_Posts

Then add your normal loop underneath this

Leave a Comment