Template Dropdown not showing up within Wordpress

2019-03-12 15:52发布

I am working on a Wordpress-based project, and I just added a new template to the installation by uploading a template file. I was creating a new page that will use my new template, when suddenly, the "Template" dropdown in the "Page Attributes" box is gone.

I am using Wordpress 3.0.1.

Update: I saw a site which told me to revert to the default template, and back to my custom template. Apparently it worked, but I am still baffled on what triggers this bug. Also, any additional knowledge or pointers on this bug would be a great help since my job requires me to patch this (and possibly submit the bug fix to Wordpress). Thanks!

16条回答
Evening l夕情丶
2楼-- · 2019-03-12 16:24

I have found a different solution for this. I reactivated my custom theme but then problem persisted.. then in the top most section of the code for the custom page template where it actually defines the name of the template like this:

<?php
    /*
     Template Name: Front Page
    */
?>

I did this:

<?php
    /**
    * Template Name: Front Page
    */
?>  

Then refreshed the admin panel and it appeared.Seems a bit weird but it worked for me. Feel happy to share this.

查看更多
Lonely孤独者°
3楼-- · 2019-03-12 16:25

I've had this problem for two days. This forum and a couple of tests later did the work. Here is what was missing for my part.


Be sure that there is a style.css in your theme folder.

The style.css must have a valid comment section at the top of the file. This means at least this:

/*!
Template: your-theme
*/

If you're using SASS or LESS, make sure that you have a "!" just after declaring your comment. It's to prevent SASS or LESS to delete your comment section.

To be sure that everything is settled fine. You may go to "Appearance > Themes". After the listing of themes, if there is nothing, than everything should be fine. Otherwise, it'll be written "Broken Themes" and you'll still have some issues to solve.

查看更多
做自己的国王
4楼-- · 2019-03-12 16:25

sass had deleted the content in my child style.css. The template drop down shows again once I added back the comments. /* Theme Name: Sometheme Child Description: Child theme for Sometheme. Template: sometheme Version: 1.1 Text Domain: sometheme-child */

查看更多
smile是对你的礼貌
5楼-- · 2019-03-12 16:27

I was just facing the same issue so, the problem is in spacing between 'Template Name' and that colon.

/*
  Template Name: template-name
*/

Make sure there is no spacing before the colon.

查看更多
该账号已被封号
6楼-- · 2019-03-12 16:28

This below is work for me and show template option in page attributes.Just place .php file in theme root folder.

<?php
/* template name: my custom template */
?>
查看更多
劳资没心,怎么记你
7楼-- · 2019-03-12 16:29

Put style.css in your theme directory, instead of the css folder. Or

<?php
    /*
     Template Name: Front Page
    */
?>

There must not space between "Template Name:".

查看更多
登录 后发表回答