Page templates faded with Wordpress 3.4

I created a Wordpress theme that uses several custom page templates. According to the documentation http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates I did this simply by setting a comment at the top of my template files:

/* Template Name: MyCustomTemplate */ 

And it worked fine as long as I remember (this is not the first time I use custom page templates). Today we upgraded to Wodrpress 3.4, and suddenly the option to select a custom template disappeared from the administrator (this was in the drop-down list in the "Page Attributes" field on the right). However, if you use “Quick Edit” in the page list, the “Template” drop-down list is still displayed, but you can only select “Default template” - none of the custom templates I have configured.

According to this blog post: http://nacin.com/2012/03/29/page-templates-in-subdirectories-new-in-wordpress-3-4/ WP 3.4 added support for custom page templates inside a subdirectory, but it is unclear if this directory should be called anything special or if you still need a "template name" at the top of the files. I tried to create a "page" directory and first put an empty .php file in it, but did nothing. Then I tried to place one of my custom page templates (complete with "Template Name"), but that didn't help either.

It is worth noting that pages that have already been assigned to use a custom page template still display with this template, even if “Default Template” is specified in Quick Edit and there are no other templates in the drop-down list.

There is almost nothing to find on interwebs, but I hope one of you finds out what is happening.

+6
source share
3 answers

Well, we figured it out. As can be seen from 3.4, the name "Template Name" should look like this:

 /* Template Name: MyCustomTemplate */ 

And it will not appear in the administrator if it looks like this:

 /* Template Name: MyCustomTemplate */ 

Hope this helps someone else.

Edit: Wordpress sent us an email and said that this is a bug that will be fixed with the next version.

+13
source

Few, the big project on the line, got scared there for a moment! I'm not sure about the subdirectory templates, but as the last person commented, with a line break before and after the template name (with / * and * / on its own line) it did the trick.

The site I worked on had four basic templates for different communities, which included different headers and navigation. When custom templates break, all that happened is a drop-down menu to select a specific template. Website functionality was not compromised, and all pages continued to use the correct template. Updating template files in Dreamweaver fixed a drop-down selector.

0
source

In wordpress 3.4.2, the following template template separator is in my theme:

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

Source: https://habr.com/ru/post/918058/


All Articles