Friday, March 23, 2012

[BS] WordPress Tutorial Add nofollow to previous and next entry links

Adding this bit of code to your theme’s functions.php file should help nofollow your ‘Previous Entries’ and ‘Next Entries’ pagination links:

1 2 3 4 5 6 
function pagination_add_nofollow($content) {     return 'rel="nofollow"'; }   add_filter('next_posts_link_attributes', 'pagnation_add_nofollow' ); add_filter('previous_posts_link_attributes', 'pagnation_add_nofollow' );

Originally I was trying to hack WordPress’s next_posts_link and previous_posts_link with a filter. I even tried targeting the next_post_link and get_next_posts_links function but nothing was working for my theme.

So I took a look in the /wp-includes/link-template.php and found out there was a next_posts_link_attributes function that’s meant to accept add-on CSS and REL attributes.

Easy enough!Similar Posts:

WordPress Tutorial Add nofollow to previous and next entry links


No comments:

Post a Comment