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!

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

  • Coyld you please explain the part about adding the normal loop under that snippet? – MetalParchment Sep 29 '13 at 18:56
  • Codex: The Loop – Wrought_steel Sep 30 '13 at 1:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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