Only display featured image of the first post (2 posts)

  1. hungken
    Posted 3 years ago #

    I want to know how to displayed random post like image below:


    That is, the code will display a list of 8 random posts, but only show the first post featured image and post excerpts of it. the next post will show the title and nothing else

    Please give me the code to do this! I use it to insert a widget supports PHP, If possible, please include simple css

    Thanks for your help!!!!

    (Sorry for my english)

  2. samcrawshaw
    Posted 3 years ago #

    Something like this?

    $recent = new WP_Query("showposts=7");
    while($recent->have_posts()) : $recent->the_post();
    <?php if($counter == 1){
    <li><h3><?php the_title(); ?></h3></li>
    <li><?php the_excerpt();?></li>
    <?php if($counter > 1){?>
    <li><h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3></li>
    <?php endwhile; ?>

    Can't check it at the moment, might have errors.

    Sorry, your on your own with the CSS.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.