0

Let's say I've got some posts and some of them are sticky. The sticky posts are displayed at the very top in The Loop.

while( have_posts() ) {
  the_post();
  get_template_part();
}

How can I add some text after all sticky posts?

0

OK I got it.

First of all, add a counter before The Loop.

$my_posts = 0;

Then in The Loop increment it by one each time.

$my_posts++;

Stickies are always at the very top, so compare the number of all sticky posts with current post in The Loop and display custom message.

if( $my_posts === count( get_option( 'sticky_posts' ) ) )
  echo 'this will only appear after all sticky posts';

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.