【发布时间】:2020-10-08 12:12:37
【问题描述】:
无法在页面属性模板中获取我自定义创建的页面,其余所有页面仍显示在下拉列表中,但未列出新创建的页面。我在PHP中创建了一个自定义页面,并将其上传到根目录的wp-content->themes->my-theme。
请帮忙,谢谢
【问题讨论】:
标签: wordpress custom-wordpress-pages
无法在页面属性模板中获取我自定义创建的页面,其余所有页面仍显示在下拉列表中,但未列出新创建的页面。我在PHP中创建了一个自定义页面,并将其上传到根目录的wp-content->themes->my-theme。
请帮忙,谢谢
【问题讨论】:
标签: wordpress custom-wordpress-pages
在自定义页面的开头添加:
<?php
/*
Template Name: Template name
*/
?>
第二个模板名称将是您的模板名称
【讨论】:
确保您的模板文件名类似于 page_{template-name} 而不是 page-{template-name}。
还要在模板的开头添加这个。
<?php /* Template Name: Example Template */ ?>
查看更多详情https://developer.wordpress.org/themes/template-files-section/page-template-files/
【讨论】: