Hi i’m using the code below to call post from a certain Category under certain post types, But how do i style it so that i can make the first post different from the rest of the post.

<?php
$queryObject = new  Wp_Query( array(
        'showposts' => 4,
        'post_type' => array('pretty-little-liars', 'revenge', 'once-upon-a-time'),
        'category_name' => celebrity,
            'orderby' => 1,
        ));
// The Loop!
if ($queryObject->have_posts()) {
?>

<?php
while ($queryObject->have_posts()){
    $queryObject->the_post();
    ?>

<a href="https://wordpress.stackexchange.com/questions/81764/<?php the_permalink(); ?>" title="<?php printf(__( 'Read %s', 'wpbx' ), wp_specialchars(get_the_title(), 1)) ?>">
                    <?php the_post_thumbnail('video-post'); ?>
                    </a>

<?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?>

               <a href="https://wordpress.stackexchange.com/questions/81764/<?php the_permalink(); ?>"><?php the_title(); ?></a>


<?php
}
?>
<?php wp_reset_postdata();
}
?>

3 Answers
3

You could check current_post in the loop:

if($queryObject->have_posts()) {
    while($queryObject->have_posts()) {
        $queryObject->the_post();
        if( 0 == $queryObject->current_post ) {
            // this is the first post
        } else {
            // not the first post
        }
    }
}

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *