Nội dung tiếp thị

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 là CMO của mởINSIGHTS và người sáng lập ra Martech Zone. Douglas đã giúp hàng chục công ty khởi nghiệp MarTech thành công, đã hỗ trợ thẩm định hơn 5 tỷ USD trong các thương vụ mua lại và đầu tư của Martech, đồng thời tiếp tục hỗ trợ các công ty triển khai và tự động hóa các chiến lược tiếp thị và bán hàng của họ. Douglas là một chuyên gia và diễn giả về chuyển đổi kỹ thuật số và MarTech được quốc tế công nhận. Douglas cũng là tác giả đã xuất bản sách hướng dẫn của Dummie và sách lãnh đạo doanh nghiệp.

Bài viết liên quan

Back to top
Đóng

Đã phát hiện ra khối quảng cáo

Martech Zone có thể cung cấp cho bạn nội dung này miễn phí vì chúng tôi kiếm tiền từ trang web của mình thông qua doanh thu quảng cáo, liên kết đơn vị liên kết và tài trợ. Chúng tôi sẽ đánh giá cao nếu bạn xóa trình chặn quảng cáo của mình khi bạn xem trang web của chúng tôi.