我想为注释创建自定义设计。comments_template()
将加载默认值\\comments.php
.
我的插件中有一个文件commentsnew.php
如何将此文件用于comments_template()
?
正在相对于主题目录加载文件。
apply_filters( \'comments_template\', string $theme_template )
这将完全覆盖模板,但不希望完全覆盖,但仅在使用时应用。
我想为注释创建自定义设计。comments_template()
将加载默认值\\comments.php
.
我的插件中有一个文件commentsnew.php
如何将此文件用于comments_template()
?
正在相对于主题目录加载文件。
apply_filters( \'comments_template\', string $theme_template )
这将完全覆盖模板,但不希望完全覆盖,但仅在使用时应用。
您可以使用comments_template
筛选以更改您的CPT将用于注释的文件。
function wpse_plugin_comment_template( $comment_template ) {
global $post;
if ( !( is_singular() && ( have_comments() || \'open\' == $post->comment_status ) ) ) {
// leave the standard comments template for standard post types
return;
}
if($post->post_type == \'business\'){ // assuming there is a post type called business
// This is where you would use your commentsnew.php, or review.php
return dirname(__FILE__) . \'/review.php\';
}
}
// throw this into your plugin or your functions.php file to define the custom comments template.
add_filter( "comments_template", "wpse_plugin_comment_template" );
我只能找到编辑输入和相关字段的帖子。如何构造编辑以包含正确的架构标记?(我已经写下了应该是什么)