How To Remove Tags & Categories From WordPress Posts
If you’re anything like me, you spend a lot of time building WordPress sites for clients. For the vast majority of these sites, they either don’t require a blog, or the blog is not the main focus of the site. WordPress has a user interface that is generally user friendly, however it’s good to cut back on unnecessary functionality. Post tags are extraneous to the needs of most business blogs and it’s usually best that they be removed. This prevents users being confused by options that aren’t needed. Additionally, tags can be dangerous for SEO if implemented incorrectly.
Removing tags from your WordPress site
Copy the following code into your
functions.php theme file or drop it into your
mu-plugins directory to remove tags.
This code removes tags using the
unregister_taxonomy_for_object_type function (developer reference). This removes all metaboxes and admin pages. However this only covers administrative features, if your posts already have tags applied, they’ll still display on the front end.
Removing tags from the front end
There are a variety of different functions that can be used to retrieve and display the tags for any given post. These functions include:
We can prevent tags from displaying on posts by filtering what these functions return and forcing them to act as though there are no tags.
Preventing tag archives from displaying
Unfortunately all the code provided doesn’t actually remove the tag archives of any existing tags, which still leaves us with those redundant tag archive pages. Removing the links is not enough if you have posts with existing tags, as these tag archives have likely been indexed by search engines already. What we need to do to prevent archive pages from still working is to hijack the main WordPress query and force it to act as though those pages don’t exist.
Removing categories and other taxonomies
You can replicate this technique for any other taxonomy, such as post categories, or WooCommerce product tags and categories.
Adding these few lines of code to your WordPress site will make managing your website easier and avoid SEO issues.