0

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(); ?>
5
  • Then you must have tons of sticky posts. That's why your latest posts do not appear on first page of blog page.
    – Robert hue
    Oct 20, 2014 at 19:40
  • @Roberthue No, I have only three sticky posts, and six posts total. The blog is set to show up to twenty posts.
    – Jaeeun Lee
    Oct 20, 2014 at 19:45
  • Do you have different pages for blog and homepage each? The code you posted, is it for blog page too?
    – Robert hue
    Oct 20, 2014 at 19:50
  • @Roberthue I just found the post toward the bottom of the blog page. I think the issue is that the sticky posts are showing first and then regular posts.
    – Jaeeun Lee
    Oct 20, 2014 at 19:51
  • That's what sticky post means. You stick them at the top. Also, when you do not need them to stick at top, make sure you unsticky them other wise your other blog post will bury in stickies.
    – Robert hue
    Oct 20, 2014 at 19:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.