Created
October 30, 2011 00:54
-
-
Save billerickson/1325314 to your computer and use it in GitHub Desktop.
Add rel=nofollow to categories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add rel=nofollow to wp_list_categories | |
* @link http://www.billerickson.net/adding-nofollow-to-category-links/ | |
* @author Bill Erickson | |
*/ | |
function add_nofollow( $text ) { | |
$text = stripslashes($text); | |
$text = preg_replace_callback('|<a (.+?)>|i', 'wp_rel_nofollow_callback', $text); | |
return $text; | |
} | |
add_filter( 'wp_list_categories', 'add_nofollow' ); | |
/** | |
* Add rel=nofollow to the_category | |
* @link http://www.billerickson.net/adding-nofollow-to-category-links/ | |
* @author Bill Erickson | |
*/ | |
function add_nofollow_cat( $text ) { | |
$text = str_replace('rel="category tag"', "", $text); | |
$text = add_nofollow($text); | |
return $text; | |
} | |
add_filter( 'the_category', 'add_nofollow_cat' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment