如何在wordpress页面中显示页面模板名称

时间:2017-06-21 06:25:23

标签: wordpress

1 - 我想知道模板名称在WordPress页面的下拉列表中自动出现的逻辑

2 - 只需在template-page.php中编写,以及如何从template-page.php获取WordPress后端页面中的模板名称

谢谢

2 个答案:

答案 0 :(得分:1)

如果我没有错,那么你的问题与创建模板有关,那么你需要创建一个文件然后开始

 /**
     * Template Name: My Awesome Custom Page
     * This is the most generic template file in a WordPress theme
     * and one of the two required files for a theme (the other being style.css).
     * It is used to display a page when nothing more specific matches a query.
     * E.g., it puts together the home page when no home.php file exists.
     *
     * @link http://codex.wordpress.org/Template_Hierarchy
     *
     * @package WordPress
     * @subpackage Twenty_Sixteen
     * @since Twenty Sixteen 1.0
     */

之后只需复制粘贴index.php文件的代码,它将在admin中显示到页面部分。 check tutorials

答案 1 :(得分:0)

用于在激活的主题文件夹中创建自定义模板创建文件。例如,如果您的自定义模板名称是“home_custom_template”。 在您的文件中编写代码:

    <?php
    /*
    Template Name: home_custom_template
    */
    get_header();
    ?>
          /*
             Your Php and html code here...
          */

 <?php get_footer();?>

1))

     /*
        Template Name: home_custom_template
     */

此代码定义为wordpress,这是模板。

2))  创建新页面在wordpress中,第一页右侧的模板下拉列表。你可以在那里找到你的模板。因此,请选择自定义模板并发布页面。

您可以在此处找到更多信息:How to create a custom template

相关问题