I set my home page to show the latest three sticky posts from the blog.
The problem is, if you publish a post that's not sticky, it doesn't show up in the blog page.
How could I fix it?
The code below is in my homepage template.
<?php
$sticky = new WP_Query( array(
'post__in' => get_option( 'sticky_posts' ),
'posts_per_page' => 3,
'ignore_sticky_posts' => true,
// date descending is default sort so we don't need it explicitly
) );
while ( $sticky->have_posts() ) : $sticky->the_post();
?>
<div class="box">
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<a href="<?php the_permalink(); ?>"><?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail();
}
?></a>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>