Content Marketing

WordPress rel=”prev” and rel=”next”

Quite a few years ago, folks would fine-tune their pages using a technique called nofollow. Basically, if you wrote rel=”nofollow” within an anchor tag (a link), the theory was that the search engine would ignore that link and ignore the next page. It’s been used extensively by sites like Wikis and within comments so that user-edited links wouldn’t be abused and followed.

Search Engine consultants quickly realized how useful these types of links were, sprinkling them throughout links on the page so that some links were weighted more heavily than others. The practice was called page-sculpting and was eventually looked down upon by Google.

I still utilized nofollow on my pagination links (those are the next and previous links) on the site. That way my pages (2, 3, 4, etc.) wouldn’t be included in search results. I did this by a modification I found on Katz Web Services page.

Last week, Google provided an update where pagination links could be coded with rel=”next” and rel=”prev” within the anchor tags. Thankfully, the functions (which should be added to your theme’s functions.php file) are quite easy to edit. Here they are with the update.

Customization for Next Page links:

function mtb_next_posts_link($label='Next Page', $max_page=0) {
	global $paged, $wp_query;
	if ( !$max_page ) {
		$max_page = $wp_query->max_num_pages;
	}
	if ( !$paged )
		$paged = 1;
	$nextpage = intval($paged) + 1;
	if ( (! is_single()) && (empty($paged) || $nextpage >= $max_page) ) {
		echo '>a rel="next" href="';
		next_posts($max_page);
		echo '" title="Next page – Go to page '.$nextpage.'">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'>/a>';
	}
}

Customization for Previous Page links:

function mtb_previous_posts_link($label='Previous Page') {
	global $paged;
	if ( (!is_single())	&& ($paged > 1) ) {
		$prevpage = intval($paged) – 1;
		echo '>a rel="prev" href="';
		previous_posts();
		echo '" title="Previous page – Go to page '.$prevpage.'">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'>/a>';
	}
}

Add those functions to functions.php and then use the function in your index.php and other pages where pagination links are utilized. That’s all it takes to implement this new feature on your WordPress site or blog – something I’d highly recommend! Hopefully, the developers of WordPress will implement this change within the core application. To date, they haven’t paid much attention to search engine optimization, though, so I’m not holding my breath.

Douglas Karr

Douglas Karr is CMO of OpenINSIGHTS and the founder of the Martech Zone. Douglas has helped dozens of successful MarTech startups, has assisted in the due diligence of over $5 bil in Martech acquisitions and investments, and continues to assist companies in implementing and automating their sales and marketing strategies. Douglas is an internationally recognized digital transformation and MarTech expert and speaker. Douglas is also a published author of a Dummie's guide and a business leadership book.

Related Articles

Back to top button
Close

Adblock Detected

Martech Zone is able to provide you this content at no cost because we monetize our site through ad revenue, affiliate links, and sponsorships. We would appreciate if you would remove your ad blocker as you view our site.