Template Dropdown not showing up within Wordpress administrator page

我的未来我决定 提交于 2019-12-03 09:38:48

问题


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!


回答1:


If you have disabled or removed the style.css from the template directory then also it will not work.

So there must be the style.css on template directory then the templates directory will be shown. When you try to remove the style.css from the template directory or using style.css from css folder, then you must be put one style.css on template directory.

Thanks




回答2:


Morichika is spot on. I had the same problem, but then it sorted itself out by doing:

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



回答3:


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.




回答4:


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:".




回答5:


I managed to fix this by making sure the style.css in the theme root contained the theme comments. I accidentally deleted mine and it removed the templates dropdown.

https://codex.wordpress.org/Theme_Development#Theme_Stylesheet




回答6:


I had the exact same problem with WordPress 3.2.1. I added a new template and the menu disappeared from the page add/edit screen. The solution was to switch back to the default twentyeleven theme end then right back to my custom theme. The templates drop-down began appearing again.

BTW, you said "revert to the default template, and back to my custom template" but I'm pretty sure you meant theme. I'm guessing where you saw this was here:

http://wordpress.org/support/topic/template-file-drop-down-not-appearing

Looks like this bug has existed for a couple of years at least. I filed a report: http://core.trac.wordpress.org/ticket/18324




回答7:


I know is super late for this question, but I fix it adding

Version: 0.1 alpha

in the comments of the themeFolder/style.css

This is my style.css complete for my theme

/*
  Theme Name: Stockout Theme
  Theme URI: http://stockout.com.uy/myTheme
  Author: MauriPastorini
  Author URI: http://stockout.com.uy
  Description: This is a theme for stockout page
  Version: 0.1 alpha
*/

I hope someone find this useful




回答8:


I tried many of the suggested answers. None worked in my case.

A possible reason for the Template Dropdown not showing is a missing index.php in your Theme folder.

Just create an empty one, in case your hierarchy does not need one. But the existance of that file enables the option to choose the page template and suppresses an error message in the Choose-Theme page btw




回答9:


I had this problem a while back and found one janky solution after a lot of search--sometimes switching to another theme in your install and then switching back to you primary theme will make your templates appear. I know that sounds weird, but worked for me for a while.




回答10:


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.




回答11:


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 */




回答12:


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.




回答13:


I found the root of the problem. It is the style.css file inside the theme root.

  1. It must be in "UNIX encoding".

  2. It must have all comments with "Theme Name", "Version", etc.




回答14:


Jack Nicholson was right! You need to make sure your style.css contains the full comment. Example below:

Previously mine was:

/*
Theme Name: Acadata
Theme URI: https://www.factorypattern.co.uk
Description: Custom
Author: Factory Pattern
Version: 1
License: GNU General Public License
License URI: license.txt
*/

Then I changed it to the below and now I can see all my templates.

/*
Theme Name: Acadata
Theme URI: https://factorypattern.co.uk/
Description: Custom
Author: Factory Pattern
Author URI: https://factorypattern.co.uk/
Description: The Acadata theme for WordPress.
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: black, brown, orange, tan, white, yellow, light, one-column, two-columns, right-sidebar, flexible-width, custom-header, custom-menu, editor-style, featured-images, microformats, post-formats, rtl-language-support, sticky-post, translation-ready
Text Domain: acadata

This theme, like WordPress, is licensed under the GPL.
Use it to make something cool, have fun, and share what you've learned with others.
*/



回答15:


Please set properly you style.css file specially if you are working on child-theme

/*
Theme Name: Theme Name
Theme URI: http: //mysite.com/
Description: This is a custom child theme for xxx theme
Author: My Name
Author URI: http: //mysite.com/
Template: template_name_in_lowercase
Version: 0.1
*/



回答16:


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 */
?>



回答17:


There are a lot of great answers on this question, but one obvious solution, which initially escaped me, was to double-check that in Dashboard > Settings > Reading you want to set "Your homepage displays" to "Static Page" and then leave the "Posts Page" unselected.

While themes and a properly coded theme file play a role in the situation, the reason that the page attributes area on the edit page screen doesn't show the templates drop-down may be because you selected a particular page to be your "Posts Page", and so WordPress is not asking you for a custom template to use because it's already using front-page.php or home.php (See WordPress Template Visual Hierarchy).

Hope this helps someone like me who had a properly coded template file but didn't realize this setting had been selected.



来源:https://stackoverflow.com/questions/3987773/template-dropdown-not-showing-up-within-wordpress-administrator-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!