WordPress :对自定义 post 类型的评论
WordPress : comments on custom post type
感谢 WordPress 上的 ACF,我创建了一个名为 "Movies"
的自定义 post 类型,我想启用对这些 post 的评论。我在这里找到了一些帮助,修改了 functions.php
文件,但它仍然不起作用...
这是我在 "only admin"
部分插入的代码。我不知道我这样做是否正确...
我不是开发人员。这是我的代码。
感谢您的宝贵时间。
// 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 );
'init' 钩子的回调函数名称错误。它不应该 register_cpt_movie
而不是 movie
.
更新后的代码是:
// 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 );
}
感谢 WordPress 上的 ACF,我创建了一个名为 "Movies"
的自定义 post 类型,我想启用对这些 post 的评论。我在这里找到了一些帮助,修改了 functions.php
文件,但它仍然不起作用...
这是我在 "only admin"
部分插入的代码。我不知道我这样做是否正确...
我不是开发人员。这是我的代码。
感谢您的宝贵时间。
// 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 );
'init' 钩子的回调函数名称错误。它不应该 register_cpt_movie
而不是 movie
.
更新后的代码是:
// 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 );
}