Avoid rel=”nofollow” on wordpress how to

I think a Page for this modification argument should be added to help anybody like to hack his wordress for this.

This page is dedicated so to the tricky i have think to solve the issue about arbitrary nofollow addition to <a> tags on WordPress, and without adding a plugin, but still with all possibles features about who should or not be affected by this wordpress behavior ( addition of rel=”nofollow” on a tags ). You can also choose to avoid for any other user level the auto addition of rel=”nofollow”, the hack can be adjusted with easy as much we like.

Hacking formatting.php to avoid nofollow additions on <a> tags in WordPress

in this example we go to avoid the rel=”nofollow” additions on <a> tags only for administrators when they add contents to blog.

OPEN the file wp-includes/formatting.php file with a text editor and search for these following two lines of code as indicated and add the code (the mentioned lines of code are related the two functions involved on wordpress rel=”nofollow addition and are sequentially).

Search the following line of code:
function wp_rel_nofollow( $text ) {
immediately after this line ADD the following code:
// START hack to avoid admin rel="nofollow"
global $current_user;
if($current_user->user_level > 9){
return $text;
}

// END hack to avoid admin rel="nofollow"

Search the following line of code:

function wp_rel_nofollow_callback( $matches ) {
immediately after this line ADD the following code:
// START hack to avoid administrators rel="nofollow"
global $current_user;
if($current_user->user_level > 9){
return $text;
}

// END hack to avoid admin rel="nofollow"

Save the file and upload overwriting the default formatting.php. Now when an user with administrative power go to post contents, WordPress will not add the rel=”nofollow” attribute.

Bookmark and Share

One Response to Avoid rel=”nofollow” on wordpress how to

  1. axew3 says:

    More examples for different scenario on avoiding rel nofollow addition in WordPress posts, pages or comments: authors, contributors …

    instead of:

    // START hack to avoid administrators rel="nofollow"
    global $current_user;
    if($current_user->user_level > 9){
    return $text;
    }

    to avoid rel nofollow on wordpress for all users, the code that need to be added as indicated for two times in place of the above, are these following two lines of code (one is a comment in true)) substituting the above that avoid no nofollow only for administrators:
    function wp_rel_nofollow_callback( $matches ) {
    immediately after this line ADD the following code:
    // eliminate for all users the rel nofollow addition on wordpress:
    return $text;

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>