To remove the “nofollow” attribute from all internal links on your WordPress site, you can use one of the following methods:
Use a plugin:
There are several plugins available that can help you remove the “nofollow” attribute from your internal links. Some popular options include “Remove Nofollow,” “Nofollow Manager,” and “Nofollow Control.”
To install a plugin:
- Log in to your WordPress admin dashboard.
- Go to “Plugins” > “Add New.”
- Search for one of the plugins mentioned above.
- Install and activate the plugin.
- Configure the plugin settings according to your needs (each plugin may have slightly different settings).
Edit your theme’s functions.php file:
If you prefer not to use a plugin, you can manually remove the “nofollow” attribute from your internal links by editing your theme’s functions.php file. Follow these steps:
- Log in to your WordPress admin dashboard.
- Go to “Appearance” > “Theme Editor.”
- In the right sidebar, locate and click on the “functions.php” file.
- Add the following code snippet at the end of the file:
function remove_nofollow_from_internal_links($content) { $site_url = get_site_url(); $pattern = "/<a(.*?)href=[\"']" . preg_quote($site_url, "/") . "(.*?)[\"'](.*?)rel=[\"']nofollow[\"'](.*?)>/i"; $content = preg_replace($pattern, '<a$1href="' . $site_url . '$2"$3$4>', $content); return $content; } add_filter('the_content', 'remove_nofollow_from_internal_links');
or this code:
function remove_nofollow($string) { $internal = get_site_url(); if ( str_contains( $internal, $string ) { $string = str_ireplace(' rel="nofollow"', '', $string); } return $string; } add_filter('the_content', 'remove_nofollow');
- Click “Update File” to save the changes.
This code snippet will remove the “nofollow” attribute from all internal links in your site’s content. However, please be aware that editing your theme’s functions.php file can have unintended consequences if not done correctly. It’s always a good idea to create a backup of your site before making changes to the code.
If you’re using a page builder or any other custom plugin to create content, you may need to use a different method or consult the plugin documentation to remove the “nofollow” attribute from internal links.