brz0
5/16/2016 - 5:27 AM

Quick reference wordpress loop. Get the latest recent posts and use previous/next buttons

Quick reference wordpress loop. Get the latest recent posts and use previous/next buttons

// Offset posts by adding offset=1

<?php global $query_string; // required
$posts = query_posts($query_string.'&posts_per_page=7&order=DESC'); ?>

	<?php while(have_posts()) : the_post(); ?>
					
		<div id="post">
			<h1><?php the_title(); ?></h1>
			<p style="font-weight: 300;"><?php the_time('F jS, Y'); ?> // 
			<a href="#"><?php the_category(', '); ?></a></p>
			
			<?php the_content(); ?>
		</div>
	<?php endwhile; ?> 

		
		<div class="pull-left">	
			<h3><?php next_posts_link( 'Older Entries' ) ?></h3>
		</div>
		<div class="pull-right">
			<h3><?php previous_posts_link( 'Newer Entries' ) ?></h3>
		</div><br><br>
	<?php wp_reset_query(); // reset the query ?>