WordPress.org

Ready to get started?Download WordPress

Forums

NOFOLLOW in Category and Archive Sidebar links (6 posts)

  1. twdblog
    Member
    Posted 6 years ago #

    How would I make the sidebar links for Categories and Archives nofollow? There does not seem to be a plugin that will do this.

  2. Kafkaesqui

    Posted 6 years ago #

    My "really old" plugin can still take care of this (as long as you're not using sidebar widgets):

    http://guff.szub.net/2005/01/27/add-link-attribute/

  3. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    add_filter('wp_list_categories','wp_rel_nofollow'); will do the trick easily enough for the categories.

    There's no filter on the wp_get_archives function that I can find though.

  4. Kafkaesqui

    Posted 6 years ago #

    Bah! You and your crazy filters! ;)

    (Where have I read that before...)

    Let me share a personal quote from earlier this year with everyone:

    Dammit, everything in WordPress should have a filter by now. Everything!!!

    If that came true, I could stop linking to hacky plugins of mine written all the way back in 2005.

  5. twdblog
    Member
    Posted 6 years ago #

    I'm using sidebar widgets.

    I put the categories filter in the default-filters.php file, but it did not work. Does it go somewhere else?

  6. recordinghacks
    Member
    Posted 5 years ago #

    The wp_rel_nofollow() filter appears to be broken in 2.5.1 -- when I add the suggested line to default-filters.php, the category list rendered on my site's homepage has escaped quotes:

    <li class=\"cat-item cat-item-3\"><a href=\"http://example.com/foo\" title=\"View all posts filed under Colophon\" rel=\"nofollow\">Colophon</a> (10)

    I worked around this bug by cloning the wp_rel_nofollow() function to a new name and removing this line from it:
    $text = $wpdb->escape($text);
    and then updating default-filters.php with my new function name:
    add_filter('wp_list_categories','wp_rel_nofollow_mgm');

    Voila! Category links are nofollowed and there are no ugly escaped-quote issues in the source.

Topic Closed

This topic has been closed to new replies.

About this Topic