筛选\'comments_open\'
检查它发生在同名函数内部,该函数在主题中调用,通常如下所示:
comments_open() and comment_form(
array (
\'comment_notes_after\' => \'\'
)
);
这就是过滤器的工作原理:
add_filter( \'comments_open\', \'wpse_98775_comment_check\', 10, 2 );
function wpse_98775_comment_check( $open, $post_id )
{
if ( $open )
return $open;
if ( \'my_post_type\' === get_post_type( $post_id ) )
return TRUE;
return $open;
}
您可以创建
custom plugin with this snippet.