Template Dropdown not showing up within Wordpress administrator page

后端 未结 22 899
清歌不尽
清歌不尽 2021-02-01 17:49

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 templ

相关标签:
22条回答
  • 2021-02-01 18:44

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

    Put this at the top of your theme root's style.css.

    /wp-content/themes/YOUR_THEME/style.css

    /*
    Theme Name: Twenty Thirteen
    Theme URI: http://wordpress.org/themes/twentythirteen
    Author: the WordPress team
    Author URI: http://wordpress.org/
    Description: The 2013 theme for WordPress takes us back to the blog, featuring a full range of post formats, each displayed beautifully in their own unique way. Design details abound, starting with a vibrant color scheme and matching header images, beautiful typography and icons, and a flexible layout that looks great on any device, big or small.
    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: twentythirteen
    
    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.
    */
    

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

    Or if you have a custom theme...

    /*
    Theme Name: My Wordpress Theme
    Theme URI: https://example.tk
    Author: Me
    Author URI: https://example.tk
    Description: This is my custom theme
    Version: 1.0
    */
    
    0 讨论(0)
  • 2021-02-01 18:44

    Try this. template will be available for both page & post

    <?php
    /**
     * Template Name: Blog Post
     * Template Post Type: post, page
    ?>
    
    0 讨论(0)
  • 2021-02-01 18:44

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

    0 讨论(0)
  • 2021-02-01 18:46

    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.

    0 讨论(0)
  • 2021-02-01 18:46

    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 */
    ?>
    
    0 讨论(0)
  • 2021-02-01 18:47

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

    <?php
        /**
        * Template Name: Front Page
        */
    ?>
    
    0 讨论(0)
提交回复
热议问题