Template Dropdown not showing up within Wordpress administrator page

后端 未结 22 983
清歌不尽
清歌不尽 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条回答
  •  猫巷女王i
    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.

提交回复
热议问题