簡體   English   中英

WordPress:有關自定義帖子類型的評論

[英]WordPress : comments on custom post type

多虧了WordPress上的ACF,我創建了一個自定義帖子類型"Movies" ,並且希望對這些帖子啟用評論。 我在這里找到了一些幫助,修改了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 );
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM