• Resolved johnnygjr

    (@johnnygjr)


    Hey folks,

    Here’s the code I’m currently using to display the most recent post as a full (the_content) post, while all others below and on other pages (other than home) are truncated (the_excerpt).

    <?php if( $wp_query->current_post == 0 && !is_paged() ) the_content('<p><span class="readmore">Read More &rarr;</span></p>'); else the_excerpt(); ?>

    What I’d like to do is simply display the TWO most recent posts on the home page instead of just one.

    Thoughts?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Michael

    (@alchymyth)

    adapt the conditional statement:

    <?php if( $wp_query->current_post <= 1 && !is_paged() ) the_content('<p><span class="readmore">Read More &rarr;</span></p>'); else the_excerpt(); ?>

    $wp_query->current_post is the loop counter for the post position, starting with 0 zero for the first post in the loop…

    Thread Starter johnnygjr

    (@johnnygjr)

    Awesome! I had no idea current_post worked as a counter. That makes things really easy.

    Thanks again, alchymyth.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display the_content for top two posts on home page’ is closed to new replies.