Have you ever want to display the latest sticky posts as featured posts at the top of the page? In this answer, we have share how to show the latest sticky posts in WordPress. Sticky Posts in WordPress is really easy to get more traffic on some featured posts of your blog.
Add the below code at the end of your theme’s functions.php file or you can also add the below code inside your site-specific plugin.
// show the latest sticky posts in wordpress
$sticky = get_option( 'sticky_posts' );
rsort( $sticky );
$args = array(
'post__in' => $sticky,
'posts_per_page' => 5,
'ignore_sticky_posts' => 1
$sticky_query = new WP_Query( $args );
// the loop
if ( $sticky_query->have_posts() ) :
while ( $sticky_query->have_posts() ) : $sticky_query->the_post();
get_template_part( 'content', get_post_format() );
get_template_part( 'content', 'none' );
Note: If you want to change the number of sticky posts to display, then change
posts_per_page values post query.
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.