Wordpress 在另一个模板中包含模板

Wordpress Include template in another one

我有一个自定义 wordpress 模板,我想在其中包含另一个模板。 基本上我有一个评论表单,我想在其中包含一个字段来编辑用户显示名称,这个字段在另一个模板中。

这是我的文件夹结构:

我想在 review-template.php 中包含 user-display-name-template.php(即在子子文件夹 review-template-folder 中) 获得此结果的最佳方法是什么。 感谢您的帮助。

您尝试过使用 'get_template_part' 吗?

https://developer.wordpress.org/reference/functions/get_template_part/

所以在你的情况下你会使用:

get_template_part('user-display-name-template');