Content Màrqueting

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

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 és CMO de OpenINSIGHTS i el fundador de la Martech Zone. Douglas ha ajudat a desenes d'empreses d'èxit de MarTech, ha ajudat en la diligència deguda de més de 5 mil milions de dòlars en adquisicions i inversions de Martech i continua ajudant les empreses a implementar i automatitzar les seves estratègies de vendes i màrqueting. Douglas és un expert i conferenciant de MarTech en transformació digital reconegut internacionalment. Douglas també és autor publicat d'una guia de Dummie i d'un llibre sobre lideratge empresarial.

Articles Relacionats

Torna al botó superior
a prop

Adblock detectat

Martech Zone és capaç de proporcionar-vos aquest contingut sense cap cost perquè monetitzem el nostre lloc mitjançant ingressos publicitaris, enllaços d'afiliats i patrocinis. Agrairem que elimineu el bloquejador d'anuncis mentre visualitzeu el nostre lloc.