Showing Next And Previous Link Post In WordPress

<?php
/**
*  Infinite next and previous post looping in WordPress
*/
if( get_adjacent_post(false, ”, true) ) {
previous_post_link(‘%link’, ‘&larr; Previous Project’);
} else {
$first = new WP_Query(‘posts_per_page=1&order=DESC&post_type=portfolio’); $first->the_post();
echo ‘<a href=”‘ . get_permalink() . ‘”>&larr; Previous Project</a>’;
wp_reset_query();
};

if( get_adjacent_post(false, ”, false) ) {
next_post_link(‘%link’, ‘Next Project &rarr;’);
} else {
$last = new WP_Query(‘posts_per_page=1&order=ASC&post_type=portfolio’); $last->the_post();
echo ‘<a href=”‘ . get_permalink() . ‘”>Next Project &rarr;</a>’;
wp_reset_query();
};

?>

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

Blog at WordPress.com.

Up ↑

%d bloggers like this: