3

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

2

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

2
  • Coyld you please explain the part about adding the normal loop under that snippet? Sep 29, 2013 at 18:56
  • Codex: The Loop Sep 30, 2013 at 1:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.