$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>Static page won't identify template|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Static page won't identify template

matteradmin7PV0评论

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.

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.

Share Improve this question asked Nov 24, 2018 at 17:24 ConorBaumgartConorBaumgart 1033 bronze badges 2
  • Check the classes of <body>, it could be loading an archive/etc., which usually overwrites custom pages – kero Commented Nov 24, 2018 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 Commented Nov 24, 2018 at 17:38
Add a comment  | 

1 Answer 1

Reset to default 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.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far