I've made a custom news page using a custom page template and this is my query for latest posts:
if ( have_posts() ) :
while ( have_posts() ) : the_post();
the_content(); ?>
<div class="line2"></div>
<?php endwhile;
endif;
wp_reset_query(); ?>
<!-- Start latest post -->
<?php $latest_post = get_posts( 'numberposts=5' ); // Defaults args fetch posts starting with the most recent
foreach( $latest_post as $post ) : setup_postdata( $post ); ?>
<div class="newsthumb">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
</div>
<div class="newstitle">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</div>
<div class="postdate-category">
<?php esportsheaven_posted_on(); ?> | <?php the_category(); ?>
</div>
<div class="newscontent">
<?php the_excerpt(); ?>
</div>
<?php endforeach;
wp_reset_query();
There should be 5 posts initially on the page and when the site gets more then 5 posts, I'm looking to add pagination. What's the best/most efficient way to do this?