top of page

How to Customize WordPress Archives For Categories And Tags

If you are familiar with WordPress, you will know how to use tags and categories to organize blog posts. While using custom post types in WordPress, you will have to arrange them like categories and tags. Categories and tickets can be described as taxonomies. WordPress permits you to create any number of custom taxonomies. Though these custom taxonomies work similar to categories or tags, they are different. Here we learn how to create custom taxonomies.

How to Customize WordPress Archives For Categories And Tags

Using conditional tags

It is possible to add any custom template to achieve a unique view for any category or tag or custom taxonomy. All you need to do is to carry out a few simple changes. Never create too many templates as this will require you to adjust every model when you attempt to make some overall changes to the basic HTML markup you are using in every model in the theme. Unless you want a template that is drastically different from the theme’s archive.php, it is good to confine yourself to adding conditional changes to archive.php.

WordPress offers conditional functions to decide is a category or tag or taxonomy is displayed. To choose to show a category archive, use is_category() for categories, is_tag() for tags and is_tax() for custom taxonomies. You can also use the is_tag(), and is_category() functions to test specific categories or tags by slug or ID. For custom taxonomies, you can use the is_tax() function can be used to find out if any taxonomy (excluding categories and tags), a particular taxonomy or a particular term in a taxonomy is displayed.

Creating Custom Taxonomies

You can add a custom taxonomy is any one of the three ways. For instance, you can code it manually following the instructions in the Codex (most experts do not recommend this). Secondly, you can generate the code with the help of GenerateWP. Thirdly, you can use a plugin to get custom content types like Pods or Types. In the case of custom types, plugins enable you to create custom taxonomies and custom post types in WordPress backend. This process does not need you to write any code. This is perhaps the easiest way to add a custom taxonomy that will give you a framework to work with custom content types.

If you choose to follow any one of the first two options rather than using a plugin, you will need to add the code to a custom plugin or the theme’s functions.php file. It is good to create a custom plugin than to add the code to functions.php. Even when you are creating a plugin for the first time, this must be done. By adding the code to the theme’s functions.php, you can make it work. Nevertheless, when you switch themes while deploying a new theme or troubleshooting an issue, the taxonomy will cease to work.

While writing your custom taxonomy code as directed by the Codex or while generating it with GenerateWP, you have to paste it in a text file and add a single line of code before it. This will give you a plugin. You can upload it and install in a similar way you will do any other plugin.

#categories #Tags #websitedevelopment #Wordpress #websitedesign

1 view

Discover the right solutions for an efficient organization

Need more Cultivating News?

Never miss an update

Thanks for submitting!

bottom of page