Create archive for custom posts

Hello,

I want to have an archive page on my website for a custom post type that I use. I think this is not directly supported by the X theme. So I downloaded the x-child theme (I use it for other customizations as well) and want to add a custom archive for my custom post type.

So I created a custom archive in my child theme the way it is described here:

However, this doesn’t seem to work for me. It doesn’t show any posts on my custom archive, only showing the “NOTHING TO SHOW RIGHT NOW” message. I checked what template is being used and it seems that the index.php is still used, instead of the custom archive page I used.

What could I be doing wrong?

The first thing to check would be that your filename is correct to the CPT slug: archive-cptslug.php
Next thing to check would be that this file is in the root folder of the child theme, and the child theme is active.
Third would be to ensure any caching has been cleared, just in case.

X theme’s use of an index.php is actually good for people who want to make custom templates, as it’s a last case scenario fallback. You can see the standard hierarchy here: https://developer.wordpress.org/themes/basics/template-hierarchy/

2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.