I have created a custom post type called “Projects”.

My permalinks settings is postname and I’d like to keep it that way.

I created a page template named projects.php (Template Name: Projects) and added the script to list the projects in this page.

I added a page with the template selected as Projects.

However, when I’m viewing this page in the frontend, it calls the default archive page instead of the Projects page template.

How do I fix this?

The default archive page has its own format for displaying stuff, for example, the page title displays like Catagory: Projects.

I want a separate page template for the projects page and keep the archive page for the categories and tags. Just like for the blogs there’s a blog page and then a separate archive page, I want something similar for the custom post type as well instead of calling an archive page for everything!

1 Answer
1

Custom page templates are for pages – not post type archives 🙂

Naming your template file as archive-projects.php will cause WordPress to select it for your Projects archive page.

You also don’t need the /* Template Name: Projects */ in there, as this template naming is default WordPress behaviour. See the visual overview of the template hierarchy to understand how you can name your template files so WordPress will select them.

Alternatively, if you are wanting to replace the default WordPress custom post type archive with your own page, just ensure your page has the same slug as the custom post type – in this case, that would be projects. You can change the slug of the page at the top of the post editor, just under the title.

Leave a Reply

Your email address will not be published. Required fields are marked *