Last active
February 2, 2017 17:52
-
-
Save jbrz0/71e55f66fd8896e7c4b0abf5b9f68632 to your computer and use it in GitHub Desktop.
Quick reference wordpress loop. Get the latest recent posts and use previous/next buttons
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment