WordPress – Page templates disappeared with WordPress 3.4

Wordpresswordpress-theming

I've created a WordPress theme that uses several custom page templates. As per the documentation http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates I've accomplished this simply by setting a comment at the top of my template-files:

/* Template Name: MyCustomTemplate */

And it's worked fine for as long as I can remember (it's not the first time I use custom page templates). Today we updated to Wodrpress 3.4 and suddenly the option to select a custom template has disappeared from the admin (it used to be a drop-down in the "Page Attributes" box to the right). However, if you use the "Quick Edit" in the list of pages the "Template" drop-down is still visible, but you can only select "Default template" – none of the custom templates that I've set up.

According to this blog post: http://nacin.com/2012/03/29/page-templates-in-subdirectories-new-in-wordpress-3-4/ WP 3.4 has added support for custom page templates inside a sub-directory, but it's unclear whether this directory needs to be named something special or if you still need the "Template Name"-comment at the top of the files. I've tried creating a "pages"-directory and first put an empty .php-file in it but that did nothing. I then tried putting one of my custom page templates (complete with the "Template Name"-comment) in there but that didn't help either.

It's worth noting that the pages that were already assigned to use a custom page template still render with that template – even though it says "Default template" in "Quick Edit" and there are no other templates available in the drop-down.

There's almost nothing to be found on the interwebs yet but I'm hoping one of you will know what's going on.

Best Answer

Well we figured it out. Apparently from 3.4 the "Template Name"-comment needs to look like this:

/*
    Template Name: MyCustomTemplate
*/

And it won't show up in the admin if it looks like this:

/* Template Name: MyCustomTemplate */

Hope this helps somebody else.

Edit: "Wordpress" emailed us and said this is a bug that will be fixed with the next version.

Related Topic