0

I have two pages, one working correctly and one broken.

The first is called Calendar and it has an ID of 34. I created a page template called page-34.php and wrote some custom code, and when I load the page the template is pulled correctly and the custom code displays correctly. I have a bunch of other pages on my site like this, and they work just like this.

And then I have the second, feisty page. It's name is FAQ and it has an ID of 35. I created a template called page-35.php and wrote some custom code, but when I load the page it just defaults to index.php.

To provide some background, I recently imported all of this content from a Drupal 7 site using a plugin. I'm wondering if something broke during that process. I'm a fairly experienced WordPress developer and I've done all my usual checks for this problem, so I'm at the point where I want to do a deeper debug.

Question: Does anyone know how to do a deep programmatic debug of the template hierarchy check? I'm not afraid to get my hands dirty in the database.

  • Check the classes of <body>, it could be loading an archive/etc., which usually overwrites custom pages – kero Nov 24 '18 at 17:28
  • @kero Ahhh yep! That's it! Thank you so much. If you want to add this as an answer, I'll mark it as correct :) – ConorBaumgart Nov 24 '18 at 17:38
0

In my personal experience, WP template hierarchy has worked without problems - so no major bug here. However, it may still be, that your page-$id.php is not used. This is usually the case, when the link could be multiple things. Archives for example have priority over regular pages.

Best is to check the CSS classes on <body> of that page, and you'll see what kind of internal page was loaded.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.