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?
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityLet'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?
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';
is_sticky
in my case... Please add an answer.