[英]WordPress : comments on custom post type
I created a custom post type called "Movies"
thanks to ACF on WordPress and I would like to enable comments on these posts. 多亏了WordPress上的ACF,我创建了一个自定义帖子类型
"Movies"
,并且希望对这些帖子启用评论。 I found some help here, modifying the functions.php
file but it still doesn't work... 我在这里找到了一些帮助,修改了
functions.php
文件,但仍然无法正常工作...
Here is the code I inserted in the "only admin"
part. 这是我在
"only admin"
部分中插入的代码。 I have no clue if I'm doing this the right way... 我不知道我是否以正确的方式这样做...
I'm not a developer. 我不是开发人员。 Here's my code.
这是我的代码。
Thanks for your time. 谢谢你的时间。
// Enable comments in ACF
add_action( 'init', 'movie' );
function register_cpt_movie() {
$labels = array(
'name' => _x( 'movie', 'movie' ),
'singular_name' => _x( 'movie', 'movie' ),
'add_new' => _x( 'Ajouter', 'movie' ),
'add_new_item' => _x( 'Ajouter une movie', 'movie' ),
'edit_item' => _x( 'Modifier', 'movie' ),
'new_item' => _x( 'Nouvelle movie', 'movie' ),
'view_item' => _x( 'Voir la movie', 'movie' ),
'search_items' => _x( 'Recherche', 'movie' ),
'not_found' => _x( 'Aucune movie trouvé', 'movie' ),
'not_found_in_trash' => _x( 'Aucune movie trouvé', 'movie' ),
'parent_item_colon' => _x( 'Parent Service:', 'movie' ),
'menu_name' => _x( 'movie', 'movie' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'supports' => array( 'title', 'editor', 'comments', 'excerpt', 'custom-fields', 'thumbnail', 'revisions', 'author', 'page-attributes' ),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 21,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'page'
);
register_post_type( 'movie', $args );
The name of the function call back for 'init' hook was wrong. 回调“ init”挂钩的函数名称错误。 It should no
register_cpt_movie
not movie
. 它应该不是
register_cpt_movie
不是movie
。
The updated code is: 更新的代码是:
// Enable comments in ACF
add_action( 'init', 'register_cpt_movie' );
function register_cpt_movie() {
$labels = array(
'name' => _x( 'movie', 'movie' ),
'singular_name' => _x( 'movie', 'movie' ),
'add_new' => _x( 'Ajouter', 'movie' ),
'add_new_item' => _x( 'Ajouter une movie', 'movie' ),
'edit_item' => _x( 'Modifier', 'movie' ),
'new_item' => _x( 'Nouvelle movie', 'movie' ),
'view_item' => _x( 'Voir la movie', 'movie' ),
'search_items' => _x( 'Recherche', 'movie' ),
'not_found' => _x( 'Aucune movie trouvé', 'movie' ),
'not_found_in_trash' => _x( 'Aucune movie trouvé', 'movie' ),
'parent_item_colon' => _x( 'Parent Service:', 'movie' ),
'menu_name' => _x( 'movie', 'movie' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'supports' => array( 'title', 'editor', 'comments', 'excerpt', 'custom-fields', 'thumbnail', 'revisions', 'author', 'page-attributes' ),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 21,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'page'
);
register_post_type( 'movie', $args );
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.