How I can remove nofollow tag from a wordpress blogpost link?

Discussion in 'WordPress' started by theprince, Jan 26, 2011.

  1. #1
    Hi,

    Like the title describe, I need a way to romove nofollow tag from a the content, not the comments.. I want when I'll add a link to the post content to be posted dofollow instead of the default nofollow.

    It exist any plugin that allow to add nofollow or dofollow link by link?

    How can I do that?

    Thanks in advance.
     
    theprince, Jan 26, 2011 IP
  2. bob25

    bob25 Well-Known Member

    Messages:
    1,519
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    128
    #2
    bob25, Jan 26, 2011 IP
  3. theprince

    theprince Well-Known Member

    Messages:
    455
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    130
    #3
    This plugin allows you to enable/disable the nofollow tag on your comments.
     
    theprince, Jan 26, 2011 IP
  4. rozer82

    rozer82 Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    just go to the footer.php and find where is the wordpress link , delete them ....
     
    rozer82, Jan 26, 2011 IP
  5. Dodger

    Dodger Peon

    Messages:
    1,494
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Just go to corner young man until you can learn how to listen.

    Here you go. Add the following to your functions.php file:

    
    / **
     * Removes the value> nofollow <from the rel attribute.
     *
     * @ Author Thomas Scholz <http://toscho.de>
     * @ Contributor David Naber <http://blog.dnaber.de/>
     * @ Version 1.1
     * @ License GPL 3 <http://www.gnu.org/licenses/gpl.html>
     * @ Param string $ str String to filtering
     * @ Return string
     * /
    function xwp_dofollow($str)
    {
        $str = preg_replace(
            '~<a ([^>]*)\s*(["|\']{1}\w*)\s*nofollow([^>]*)>~U',
            '<a ${1}${2}${3}>', $str);
        return str_replace(array(' rel=""', " rel=''"), '', $str);
    }
    
    remove_filter('pre_comment_content',     'wp_rel_nofollow');
    add_filter   ('get_comment_author_link', 'xwp_dofollow');
    add_filter   ('post_comments_link',      'xwp_dofollow');
    add_filter   ('comment_reply_link',      'xwp_dofollow');
    add_filter   ('comment_text',            'xwp_dofollow');
    
    Code (markup):
    I left the coder's attribution in tact, but you can remove that portion if you wish.
     
    Dodger, Jan 27, 2011 IP
  6. theprince

    theprince Well-Known Member

    Messages:
    455
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    130
    #6
    Thank you for the code but this one turn all the blog to dofollow, I want only the links in the post content published by me dofollow.
     
    theprince, Jan 27, 2011 IP
  7. Dodger

    Dodger Peon

    Messages:
    1,494
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I misread your post, sorry.

    If your links inside the post are nofollow, then you probably have your blog set in Privacy mode. Go to your Admin Dashboard and underneath Settings > Privacy make sure that the radio control is set to "I would like my site to be visible by everyone ..."
     
    Dodger, Jan 27, 2011 IP
  8. theprince

    theprince Well-Known Member

    Messages:
    455
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    130
    #8
    Yes it is checked and my blog is visible to all search engines, wordpress come with nofollow in post content and comments, there are some plugins that turn all the links in the blog including links on comments and in the comments URL but what I need is to be dofollow only in post content.

    I found when googling a code to add to function.php that will turn the urls in the post content dofollow but it's not compatible with the latest version of Wordpress!!
     
    theprince, Jan 27, 2011 IP
  9. Dodger

    Dodger Peon

    Messages:
    1,494
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Reworking the other code for comments will work for post content as well:

    
    function xwp_dofollow_posts($content)
    {
        $content = preg_replace(
            '~<a ([^>]*)\s*(["|\']{1}\w*)\s*nofollow([^>]*)>~U',
            '<a ${1}${2}${3}>', $content);
        return str_replace(array(' rel=""', " rel=''"), '', $content);
    }
    
    add_filter   ('the_content', 'xwp_dofollow_posts');
    
    
    Code (markup):
     
    Dodger, Jan 27, 2011 IP