WP Pagination Code

Hello Friends,
Lets go to learn WP Pagination code.
Suppose, we want to show the latest article post into our blog by last 5. The code are in below-

<h3>Recent Articles</h3>

<?php

$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query(‘showposts=5′.’&paged=’.$paged); ?>

<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
     <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
<?php endwhile; ?>

<div>
  <div><?php previous_posts_link('&laquo; Previous') ?></div>
  <div><?php next_posts_link('More &raquo;') ?></div>
</div>
<?php $wp_query = null; $wp_query = $temp;?>

This is the very simple code for showing the last 5 article post from my wp blog. Thanks fore reading this article.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s