How To Remove Tag Prefix from WordPress URL?
WordPress is a popular and versatile content management system (CMS) that powers millions of websites around the world. It provides a user-friendly interface and a wide range of themes and plugins, making it an ideal choice for bloggers, businesses, and even large-scale websites.
One of the key features of WordPress is its ability to organize content using tags. Tags are keywords or descriptive labels that you can assign to your posts, helping visitors navigate and find related content on your website. By default, WordPress adds a tag prefix to the URLs of tag archives, such as “https://yoururl.com/tag/abc/“. However, some users may prefer to remove this tag prefix to create cleaner and more concise URLs.
To remove the tag prefix in WordPress URLs, you can use either a plugin called “Remove Taxonomy Base Slug” or make modifications to your theme’s functions.php file. The plugin provides a straightforward solution, allowing you to select the taxonomy (in this case, “Tags”) for which you want to remove the prefix. On the other hand, modifying the functions.php file in a child theme offers a more customized approach for those comfortable with coding.
Regardless of the method you choose, remember to take necessary precautions such as creating a child theme before making any changes to your WordPress setup. This ensures that your modifications remain intact when you update your theme in the future. After implementing the solution, the tag prefix will be removed from the URLs, resulting in cleaner and more user-friendly links on your WordPress website.
To remove the tag prefix from URLs in WordPress, you can use a plugin or make changes to your theme’s functions.php file. Here are two methods you can try:
Method 1: Using a Plugin (Recommended)
- Install and activate the “Remove Taxonomy Base Slug” plugin. You can find and install it from the WordPress Plugin Directory.
- Once activated, go to “Settings” in your WordPress admin dashboard and click on “Remove Taxonomy Base Slug.”
- In the plugin settings, select the taxonomy for which you want to remove the prefix (in this case, “Tags”).
- Save the changes, and the tag prefix will be removed from the URLs.
Method 2: Modifying the functions.php file
- Before making any changes, it’s a good practice to create a child theme if you haven’t already. This ensures that your modifications won’t be lost when you update your theme in the future.
- In your child theme, locate the functions.php file. If it doesn’t exist, create a new file and name it functions.php.
- Open the functions.php file in a text editor and add the following code:
function remove_tag_base_slug( $tag_link ) {
return str_replace('/tag/', '/', $tag_link);
}
add_filter('tag_link', 'remove_tag_base_slug');
- Save the changes to the functions.php file and upload it to your child theme directory.
- Refresh the permalinks by going to “Settings” -> “Permalinks” in your WordPress admin dashboard and clicking the “Save Changes” button. This will flush the rewrite rules and apply the changes.
After applying either of these methods, the tag prefix should be removed from the URLs on your WordPress site. For example, instead of “https://yoururl.com/tag/abc/“, the URL will be “https://yoururl.com/abc/“.