• I’ve seen a plugin that adds the nofollow tag to links left in comments, but is there a way I can also do this for the actual post. I plan on having quite a few authors but don’t want spammers signing up and benefiting from links to their site.

Viewing 12 replies - 1 through 12 (of 12 total)
  • If you don’t mind monkeying with code, you can do this:

    Open template-functions-post.php in the wp-includes folder and find this:

    function the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
    $content = get_the_content($more_link_text, $stripteaser, $more_file);
    $content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]>', $content);
    echo $content;
    }

    then add this line just before the last line of the function:

    $content = str_replace('<a href', '<a rel="nofollow" href', $content);

    so the function now looks like this:

    function the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
    $content = get_the_content($more_link_text, $stripteaser, $more_file);
    $content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]>', $content);
    $content = str_replace('<a href', '<a rel="nofollow" href', $content);
    echo $content;
    }

    Seems to work just fine.

    sorry to hi-jack i like to know i found some where that wordpress have default no follow tag its that true ?

    i like to know i found some where that wordpress have default no follow tag its that true ?

    Yes. Commenter urls and any urls within comments are automatically given the rel=nofollow attribute.

    By the way, here’s kubicka’s idea rolled into plugin form (what can I say, I like to avoid editing the core code):

    Nofollow in Posts plugin:
    Download plugin | View source

    Only real diff with kubicka’s suggestion is I swapped out str_replace for preg_replace to perform a bit of pattern matching (in those potential cases where an author might have inserted attributes et al between <a and href).

    Kafkaesqui thank you very much looking for long time for this plugin i already open new topic long back

    one more question regarding your plugin its possible to apply
    rel=nofollow attribute only to out going (other website or blog) blog link not to own blog link

    You know, this is a heck of a lot easier, Kafkaesqui:

    add_filter('the_content', 'wp_rel_nofollow', 15);

    ??

    It is when you know the fricken function, now isn’t it V? But hey, can you solve xinfo’s last request with a one line filter plugin? ;)

    xinfo, I’ll look at modifying the plugin to do that…

    EDIT: OK xinfo, R1.0.1 (same links above) should filter out links back to the blog.

    You guys Amazing

    Thank you Kafkaesqui for considering my Request

    This plugin will help all the blog who aware of rel=nofollow
    attribute Thank you Once again

    Great plugin!

    For directing spiders I create site and category maps with Pages. These Pages are automated menus of all Posts on the website.

    The nofollow plugin is applying itself to both Posts and Pages. Is it possible to only add the nofollow command to Posts, but not Pages?

    Thanks!

    clublakers, you’ll have to modify the plugin’s source for this. Just locate the line that begins:

    $text = preg_replace(

    just above it, you can stick this line into the nofollow_in_posts() function:

    if( !is_page() )

    That will tell the plugin to perform the text ‘replace’ that inserts the nofollow only when one is *not* on a Page.

    Got it, thanks again for your help Kafkaqsqui.

    I’m using this and it works great. Is there a way to create an array of sites that can bypass the nofollow rules? Like a whitelist?

    I’ve tried coding it in myself but no luck.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘“nofollow” in posts’ is closed to new replies.