post\\u类型最多需要20个字符,不能包含大写字母或空格register_post_type();
函数您的帖子类型名称为大写Portfolio 替换为小写字母portfolio
这是我的register post类型代码段,请按照它进行操作
// add action register our post type portfolio
add_action( \'init\', \'register_cpt_portfolio\' );
// Register our Custom Post type as portfolio
function register_cpt_portfolio() {
// labels text for our post type portfolio
$labels = array(
// post type general name
\'name\' => __( \'Portfolio\' ),
// post type singular name
\'singular_name\' => __( \'Portfolio Item\' ),
\'add_new\' => __( \'Add New Portfolio Item\' ),
\'add_new_item\' => __( \'Add New Portfolio Item\' ),
\'edit_item\' => __( \'Edit Portfolio Item\' ),
\'new_item\' => __( \'New Portfolio Item\' ),
\'view_item\' => __( \'View Portfolio Item\' ),
\'search_items\' => __( \'Search Portfolio Items\' ),
\'not_found\' => __( \'No Portfolio Items found\' ),
\'not_found_in_trash\' => __( \'No Portfolio Items found in Trash\' ),
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Portfolio\'
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'query_var\' => true,
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'has_archive\' => true,
\'menu_position\' => 5,
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', \'author\', ),
\'rewrite\' => array( \'slug\' => \'portfolio-item\', \'with_front\' => false )
);
register_post_type( \'portfolio\' , $args );
}