My footer social icons widget includes a nofollow attribute in links to my social media pages. I cannot find an option to turn this off. How might I remove this attribute either with a setting or functions.php code?

  • 1
    Where did you get the widget from? It's not possible to answer this without seeing the code for the widget or knowing where it came from. If this widget is provided by a 3rd party theme then you'll need to ask their support routes as 3rd party product/service support is offtopic here
    – Tom J Nowell
    Commented Jan 14, 2023 at 17:00
  • @TomJNowell it's an inbuilt Wordpress widget, hence why I'm asking here: wordpress.com/support/wordpress-editor/blocks/…
    – user16421
    Commented Jan 15, 2023 at 6:59
  • that's not a widget, that's a block
    – Tom J Nowell
    Commented Jan 16, 2023 at 10:21

2 Answers 2


As of 6.1.1, I have discovered you can achieve this by disabling the option to open each social link in a new tab. Imagine this will change in a future WP update.

  • If you still want them to open in a new tab you could use javascript to remove it.
    – Shoelaced
    Commented Jan 15, 2023 at 15:31
  • @shoelaced How would I approach doing that?
    – user16421
    Commented Jan 16, 2023 at 19:00

You should really put this in an external file and enqueue it properly in your website footer using the WordPress default enqueue methods, either in your custom theme or from inside a custom plugin, which you can research, but to test it quickly you can drop this in at the very bottom of your theme footer.

The code should remove the nofollow value while keeping anything else in the rel attribute, noting that because they will be opening in a new tab/window, they must keep noopener and/or noreferrer to avoid security issues:

  var links = document.querySelectorAll(".social-links a[rel='nofollow']");
  links.forEach(function(link) {
    var relAttr = link.getAttribute("rel");
    var newRelAttr = relAttr.replace("nofollow ", "").replace("nofollow", "");
    link.setAttribute("rel", newRelAttr);

Also note that you will have to change the .social-links class to whatever the class name is of the WordPress social links block.

As a side note, Google's John Mueller recently tipped that you should use rel="me" for social profile links, despite other sources saying it died out years ago, so it may be worth putting that in the replace above instead of an empty string.

  • thanks. As you alluded to, to avoid this being nuked by theme updates, would you put this in the functions.php file with some PHP code or somewhere else? I am not too knowledgeable of other enqueue methods.
    – user16421
    Commented Jan 18, 2023 at 15:53
  • If you're worried about theme updates, best put it in a custom plugin. There are also plugins that let you add custom JS to your site but I've never tried any.
    – Shoelaced
    Commented Jan 18, 2023 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.