Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Customize Next and Previous Links in WordPress

Hello friends, hope you are doing good. The Next and Previous post links guide your website’s visitors through your WordPress site and it also helps you to get the more page views which boosts your SEO score. In this tutorial, I will explain how to customize Next and Previous Links in WordPress.

At the end of post and Page detail page, Next and Previous links appear to view the oldest and newest Post/page on your WordPress site. If you want to customize that links as per your site theme designs, then keep your close attention in this as I am going to share the simple & easy WordPress snippets to customize with many options.

Customize Next and Previous Links in WordPress

By default, the links will posts_nav_link looks like this:

Next and Previous Links « WordPress Codex

Want to change the text Previous Post & Next Post to something else, then use the below code:

You can add the directly previous and next post link:


Here is another way to customize the Next and Previous link by creating a new function inside the functions.php file. Use the below code in your theme’s functions.php file.

function getPrevNext(){
	$pagelist = get_pages('sort_column=menu_order&sort_order=asc');
	$pages = array();
	foreach ($pagelist as $page) {
	   $pages[] += $page->ID;
	}

	$current = array_search(get_the_ID(), $pages);
	$prevID = $pages[$current-1];
	$nextID = $pages[$current+1];
	
	echo '


This post first appeared on Programming Blog Focused On Web Technologies, please read the originial post: here

Share the post

Customize Next and Previous Links in WordPress

×

Subscribe to Programming Blog Focused On Web Technologies

Get updates delivered right to your inbox!

Thank you for your subscription

×