Page hierarchy not happening

I have 2 pages that are using the page- hierarchy and calling a template content/page - and all of a sudden they are both using an archive template instead of the default page template. They are both custom post types but I have the references all correctly set up and they were functioning as expected until today. I’m wondering what I could have changed to have them go from using the default page template to now an archive template.


This is pretty hard to answer. As you’ve said, it was working, and suddenly it’s not. Nobody here knows what code you’ve written, and how your templates are named.

The only reason an “archive” template would be used is if you have code like

<?php get_template_part('templates/content', 'page'); ?>

Which would look for sage/templates/content-page.php, and if content-page.php does not exist, it will default back to content.php. This is all explained in the codex.

Other than that, it really could be anything, as again, we don’t know what code you’ve written.

By any chance, are the names of the pages the same as the name of the post type? If so, and if the has_archive argument is set to true, then this might explain it.

Ie. say you’ve got a post type named “hotdogs”, and a page named “hotdogs”.

with has_archive => true site/hotdogs will display the archive page,
if has_archive => false then site/hotdogs will display the page.

The “worked yesterday, now it don’t” might be down to permalinks getting flushed.

It’s a long shot, but that’s all I’ve got.