我是新来的Wordpress和PHP,所以要温柔。我搜索了Wordpress文档,但无法找到答案。如何在Wordpress中创建自定义模板文件?
我需要创建一段HTML(和/或PHP)以在多个页面模板中使用。我不完全确定这是什么,但我希望它的行为与内置的Wordpress模板文件一样,如标题,边栏,页脚等...
要清楚,这是不同于创建我自己的自定义页面模板。
的用法是这样的:
// index.php
<?php get_header(); ?>
// Some index page content
<?php get_customrecentcontentsection(); ?>
// Some more index page content
<?php get_footer(); ?>
// customrecentcontentsection.php
<div>
// Some Wordpress post query with some HTML php
</div>
我会再使用<?php get_customrecentcontentsection(); ?>
在帖子模板的结尾或其他地方我认为合适的。
目前,我有index.php和post.php重复代码,我试图摆脱。
任何帮助表示赞赏。谢谢!