Template Dropdown not showing up within Wordpress administrator page

后端 未结 22 901
清歌不尽
清歌不尽 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:35

    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.

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

    This was also a problem for me and it was because of folder structure. The Theme Handbook told me a should organize my theme folder and files like so:

    assets (dir)
        - css (dir)
        - images (dir)
        - js (dir)
    inc (dir)
    template-parts (dir)
        - footer (dir)
        - header (dir)
        - navigation (dir)
        - page (dir)
        - post (dir)
    404.php
    archive.php
    comments.php
    footer.php
    front-page.php
    function.php
    header.php
    index.php
    page.php
    README.txt
    rtl.css
    screenshot.png
    search.php
    searchform.php
    sidebar.php
    single.php
    style.php
    

    The page template I was trying to load was in /template-parts/page/template-contactus.php

    I guess that was too deep for WordPress so I got ride of those directories and now my file structure looks like this:

    assets (dir)
        - css (dir)
        - images (dir)
        - js (dir)
    inc (dir)
    template-parts (dir)
        - section-content.php
        - template-contactus.php
    404.php
    archive.php
    comments.php
    footer.php
    front-page.php
    function.php
    header.php
    index.php
    page.php
    README.txt
    rtl.css
    screenshot.png
    search.php
    searchform.php
    sidebar.php
    single.php
    style.php
    

    I am now able to see the template drop-down and add templates.

    Hope this helps someone.

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

    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

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

    You will not see the dropdown if you have added 0 custom template files in your theme root.

    When at least 1 template is available, the WordPress ecosystem picks it up and the dropdown will become visible.

    Add this in your theme root to try it.

    <?php
    
    /*
     Template Name: Front Page
    */
    
    0 讨论(0)
  • 2021-02-01 18:39

    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

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

    In my case, I had called the template schedule-template-v2.php which won't work, the file name needs to be schedulev2-template.php. A simple mistake.

    0 讨论(0)
提交回复
热议问题