• Resolved myladeybugg

    (@myladeybugg)


    I am looking to make all text widget and menu widget links no follow. I looked in default-widgets.php, but couldn’t find anything in there.

    I believe there are plugins that will do this, but I am not looking to make all the links on my blogs as no follow.

    I am running multisite with buddypress.

Viewing 4 replies - 1 through 4 (of 4 total)
  • i think a plugin robots meta will help you .

    Thread Starter myladeybugg

    (@myladeybugg)

    Thanks for the plugin @andy2grant. I’ll take a look at it. I am going to need to apply this to all blogs on my network, and not do it blog by blog.

    That’s why I am looking more for a code change.

    Moderator keesiemeijer

    (@keesiemeijer)

    Try it with this in your theme’s functions.php:

    add_filter( 'wp_nav_menu_objects', 'menu_rel_nofollow', 10, 2 );
    function menu_rel_nofollow( $items, $args ) {
      foreach ($items as $item) {
        $item->xfn = 'nofollow';
      }
      return $items;
    }
    
    add_filter('widget_text', 'text_rel_nofollow');
    function text_rel_nofollow($content) {
      return stripslashes(wp_rel_nofollow($content));
    }

    This will add the nofollow to all menu item links (in or outside a widget) and to links in the widget text.

    Thread Starter myladeybugg

    (@myladeybugg)

    @keesiemeijer That code works perfectly!

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Make Links No Follow On Text and Menu Widgets’ is closed to new replies.