Showing Next And Previous Link Post In WordPress

*  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>’;

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>’;



Published by


I am a developer

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s