i want to get the last post then other posts from a specific category. This the code i got so far: CHECK THE DESIGN >>HERE<<
<?php
$args = array(
'cat' => 140, // Category ID
'posts_per_page' => 10
);
$modone_qry = new WP_Query( $args );
?>
<?php if ( $modone_qry->have_posts() ) : while ( $modone_qry->have_posts() ) : $modone_qry->the_post(); ?>
<?php if ($modone_qry->post_count === 1): ?>
<div class="one-post"><h1> LATEST POST HERE </h1></div>
<?php else: ?>
<div class="multi-post"><h1>OTHERS POSTS HERE</h1></div>
<?php endif; ?>
<?php endwhile; else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
</div>
Thanks to @Autista_z, the working code:
<?php
$args = array(
'cat' => 140, // Category ID
'posts_per_page' => 10
);
$modone_qry = new WP_Query( $args );
?>
<?php $post_number = 0; ?>
<?php if ( $modone_qry->have_posts() ) : while ( $modone_qry->have_posts() ) : $modone_qry->the_post(); ?>
<?php $post_number++; ?>
<?php if ($post_number === 1): ?>
<h1><?php the_title(); ?> BIG</h1>
<?php else: ?>
<h1><?php the_title(); ?> SMALL</h1>
<?php endif; ?>
<?php endwhile; else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
</div>
I dont know wordpress, but with simple php you can do it like this
<?php
$args = array(
'cat' => 140, // Category ID
'posts_per_page' => 10
);
$modone_qry = new WP_Query( $args );
?>
<?php $post_number = 0; ?>
<?php if ( $modone_qry->have_posts() ) : while ( $modone_qry->have_posts() ) : $modone_qry->the_post(); ?>
<?php $post_number++; ?>
<?php if ($post_number === 1): ?>
<!-- HTML of latest post - First in loop -->
<?php else: ?>
<!-- HTML of others posts -->
<?php endif; ?>
<?php endwhile; else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>