Site logo

Archived topic

Question on archive for custom taxonomy

5 replies · Started by Henry on April 5, 2019

Viewing posts 1–6 of 6

Hi, I created custom taxonomy using WordPress Pods, which works great.

However, I notice that if you visit the root of that custom taxonomy there is an error 404, i.e. there is no archive.

My custom taxonomy is 'US States' for, (hardly surprising) data that I've placed within US States! So, the actual slug is like this us-states

According to the WordPress hierarchy, I can create a template called: taxonomy-us-state.php however if I upload this to my server it doesn't load - it continues to throw the Error 404.

So, my question is - where do I place this template? Is there a resource you can share to show me how to create custom taxonomy templates? Thanks!

Hi there,

Have you tried re-saving your permalinks yet? If not, go to "Settings > Permalinks" and hit the save button. That can sometimes fix this issue.

Let me know :)

thanks Tom, but no joy.

If I apply a standard WordPress category to my Custom Post Type it doesn't show within the archive page.

If I create and apply a standard WordPress post with the same category that post shows as expected within the archive page.

What's your hunch how to fix this? Is it a GP thing?

Custom taxonomies/post types are a WordPress thing. They can be tricky sometimes.

Does this custom taxonomy apply to regular posts, or is there a custom post type?

Thanks Tom - in fact I fixed it with help from the Pods community. Here's the code that I used to 'normalize' the behavior of WordPress to call in the archive of CPT's:

add_action( 'pre_get_posts', function ( $q )
{
    if (  !is_admin() // Only target front end queries
          && $q->is_main_query() // Only target the main query
          && $q->is_category()   // Only target category archives
    ) {
        $q->set( 'post_type', ['post','custom_post_1', 'custom_post_2', 'custom_post_3'] );    }
});

^ The above came from Pods: https://docs.pods.io/code-snippets/modifying-pre_get_posts-categories-tags-show-custom-post-types/

Awesome! Glad you got it working :)

This archived topic is closed to new replies.