Page templates disappeared with WordPress 3.4

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.

Read More

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.

Related posts

Leave a Reply

3 comments

  1. 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.

  2. Phew, big project on the line, was scared there for a minute! I’m not sure about sub-directory templates but as the last person commented, having a line break before and after the template name ( having /* and */ on its own line) did the trick.

    On the site I was working on there were 4 main templates for different communities that included different headers and navigation. When the custom templates broke, all that happened was the drop down menu to choose a specific template disappeared. The website functionality did not get disturbed, and all pages kept using the correct template. Updating the template files in dreamweaver fixed the dropdown selector.

  3. In wordpress 3.4.2 following code breaked template selectbox in my theme:

    add_filter('stylesheet', 'theme_stylesheet');
    function theme_stylesheet() {
        return 'img';
    }