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

    View post on imgur.com

    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)

Viewing 1 replies (of 1 total)
  • Something like this?

    <?php
    $recent = new WP_Query("showposts=7");
    while($recent->have_posts()) : $recent->the_post();
    $counter++;?>
    <ul>
    <?php if($counter == 1){
    the_post_thumbnail();}?>
    <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; ?>
    </ul>

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

    Sorry, your on your own with the CSS.

Viewing 1 replies (of 1 total)
  • The topic ‘Only display featured image of the first post’ is closed to new replies.