我的自定义帖子类型似乎没有通过管理信息中心。我已经将它作为一个插件完成并激活它但无济于事。它不应该出现在左手边吗?我似乎也无法在代码中找到任何错误
<?php
/**
* Plugin Name: Production.
* Description: Create a new production for your website.
*/
class Production {
function __construct(){
add_action( 'init', 'my_custom_post_product' );
}
function my_custom_post_product() {
$labels = array(
'name' => _x('Productions','post type general name'),
'singular_name' => _x('Production','post type singular name'),
'add_new' => _x( 'Add New', 'Production' ),
'add_new_item' => __( 'Add New Production' ),
'edit_item' => __( 'Edit Production' ),
'new_item' => __( 'New Production' ),
'all_items' => __( 'All Productions' ),
'view_item' => __( 'View Production' ),
'search_items' => __( 'Search Productions' ),
'not_found' => __( 'No productions found' ),
'not_found_in_trash' => __( 'No productions found in the Trash' ),
'parent_item_colon' => '',
'menu_name' => 'Productions');
$args = array(
'labels' => $labels,
'description' => 'Holds the productions',
'public' => true,
'menu_position' => 5,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
'has_archive' => true,
);
register_post_type( 'Production', $args );
}
}
答案 0 :(得分:1)
您的'menu_name'设置不正确。应该是:
'menu_name' => _x( 'Production', 'Production', 'Production' ),
来源: https://codex.wordpress.org/Function_Reference/register_post_type#Example