我已经创建了一个自定义页面类型,我希望用户能够对其进行评论。乍一看,这与Comments not showing in custom post type - Wordpress, 但是,我正在使用“注释”设置“支持”值:
public function createEpisodeType() {
$labels = array(
\'name\' => \'Episodes\',
\'singular_name\' => \'Episode\',
\'menu_name\' => \'Episodes\',
\'name_admin_bar\' => \'Episode\',
\'add_new\' => \'Add New\',
\'add_new_item\' => \'Add New Episode\',
\'new_item\' => \'New Episode\',
\'edit_item\' => \'Edit Episode\',
\'view_item\' => \'View Episode\',
\'all_items\' => \'All Episodes\',
\'search_items\' => \'Search Episodes\',
\'parent_item_colon\' => \'Parent Episode\',
\'not_found\' => \'No Episodes Found\',
\'not_found_in_trash\' => \'No Episodes Found in Trash\',
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_nav_menus\' => true,
\'show_in_menu\' => true,
\'show_in_admin_bar\' => true,
\'menu_position\' => 5,
\'menu_icon\' => \'dashicons-admin-appearance\',
\'capability_type\' => \'page\',
\'hierarchical\' => true,
\'supports\' => array( \'page-attributes\', \'title\', \'editor\', \'author\', \'thumbnail\', \'excerpt\', \'comments\', \'revisions\' ),
\'has_archive\' => true,
\'rewrite\' => array( \'slug\' => \'episode\', \'with_front\' => false ),
\'query_var\' => true,
\'description\' => \'Page type that has a sequence\',
);
register_post_type(self::post_type_slug, $args);
}
当我使用Debug This检查当前查询时,我会看到post数据,包括
[comment_status] => open
我怀疑问题在于主题定制。当我看评论的时候。对于我正在使用的主题,我在顶部看到以下内容:
$comments_display = get_theme_mod( \'comments_display\' );
$post_type = get_post_type();
if ( is_array( $comments_display ) ) {
if ( ! in_array( $post_type, $comments_display ) ) {
return;
}
}
我直接检查了数据库中的选项,我看到“comments\\u display”是一个由三个值组成的数组—“post”、“page”和“none”。我的自定义类型不在该列表中。对我来说,这似乎是问题的根源。
我去了Customize: Comment Display
部分,但选项不包括我的新内容类型。
有没有办法让我的自定义类型显示在该列表中?我假设主题调用一些标准函数来获取内容类型的列表,并且我需要做一些事情来获取列表中的类型。