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

@pugh would you mind sharing any screenshots of your show posts smart action? I am trying to do somethign similar and cant get is down.

Post type is ‘our_work’
Terms Is ‘work_type’
page is exported as taxonomy-work_type.php
URL for the term would be like ‘/work_type/design/’

In my sow post smart actions I have the following -https://www.screencast.com/t/dhNHkbE9zgtY and my “The Loop” setup the same as yours.

I think I have the right template name, but maybe I just dont.

@465media I have converted my Smart Action into regular WordPress actions. If you do this, it will show the additional options that I have shared in the screenshot above. See if that helps, and if not send over the settings that you have entered and I will have another look.

@pughSo here is my structure https://www.screencast.com/t/8RZeAzBTkw3W

Site Content https://www.screencast.com/t/WvWyluXPgd0
– Show Post Smart Action setting the custom query. https://www.screencast.com/t/dhNHkbE9zgtY
---- The Loop with the query for the taxonomy terms. My Taxonomy parameters https://www.screencast.com/t/L6IYT89mSn

Is the work_type taxonomy registered to the our_work custom post type?

Also notice in my post above I needed to create archive-{taxonomy}.php and not taxonomy-{term}.php

Here are the additional settings from my Loop:

The custom post type it is being used on is events

Capto_Capture 2020-04-13_04-57-58_pm

@pugh
Yes the work_type is registered to the our_work.
image
Interesting thought and I have tried to open a ticket with support.

BlockquoteI register a custom Taxonomy for a CPT, the taxonomy list does not appear on the post edit page https://www.screencast.com/t/geeKtjGh1olL like it might on the standard post https://www.screencast.com/t/3DtiVmCs

Blockquote However it does appear in the quick edit screen on the wp-admin/edit.php?post_type=our_work See screenshot https://www.screencast.com/t/8njH029Cd5

My template works fine for the archive-our_work.php and as your suggestion I changed this to archive-work_type.php and still no results found. Frustrating.