Register archive for custom taxonomy

When registering a custom taxonomy with the WP Theme Converter, there does not seem to be the option to enable archives, like there is when registering a custom post type.

What’s the best way to enable archives for custom taxonomies created with the Theme Converter?

Hello Chris,

Generally speaking, If the option you are looking for is not available from the Pinegrow / Pinegrow Theme Converter UI, you will have to proceed differently (by adding a code snippet in functions.php for example).

For example, ​you can use the excellent generator here https://generatewp.com/taxonomy/ to create custom taxonomies with exhaustive configuration settings.

However, thanks for your suggestion, the Pinegrow Development team is now informed about your question.

note: please be aware that this is by no means a guarantee of future integration.

Have a very nice day.

You should also have a look at:
https://developer.wordpress.org/themes/template-files-section/taxonomy-templates/

Thanks Emmanual.

I realised in the end that I did not need to register an archive, but rather create the template file:

archive-{taxonomy}.php

In my case, this template file is archive-events.php (my custom post type is named “events”).

On the archive-events.php template, I then attached the Show Posts Smart Action to the appropriate part of the template, and set the Loop type to custom query. I then set the Post type to my custom post type (events).

From there, I converted the Smart Action into regular WordPress settings. I then entered the following settings as the Taxonomy parameters:

custom taxonomy

To summarise:

My custom post type is named events
A custom taxonomy (called “location”) has been registered for the events custom post type.

The above settings ensure that if someone visits /location/{location-name}/ e.g /location/london/, the template only shows events that have had the custom taxonomy of London added to them.

If anyone else has a question around this, feel free to reply.

2 Likes