Php Wordpress自定义帖子类型类
我的自定义帖子类型似乎无法进入管理仪表板。我已经做了它作为一个插件,并已激活它,但没有用。它不应该出现在左手边吗?我似乎也找不到代码中的任何错误Php Wordpress自定义帖子类型类,php,wordpress,plugins,Php,Wordpress,Plugins,我的自定义帖子类型似乎无法进入管理仪表板。我已经做了它作为一个插件,并已激活它,但没有用。它不应该出现在左手边吗?我似乎也找不到代码中的任何错误 <?php /** * Plugin Name: Production. * Description: Create a new production for your website. */ class Production { function __construct(){ add_action( 'init', 'my_c
<?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 );
}
}
您的“菜单名”设置不正确。应为:
'menu_name' => _x( 'Production', 'Production', 'Production' ),
资料来源:
您不需要将其设置为插件。这就是您的functions.php文件存在的原因。即使您将其设置为插件或单独的函数文件,您也创建了一个类,但没有调用它。类似于$Production=new Production;$Production->my_custom_product()
;否则-不会发生任何事情。