web-dev-qa-db-ja.com

カスタム投稿タイプがメニューに表示されない

私は自分のポートフォリオをカスタム投稿タイプとして管理するための簡単なプラグインを作成しました。すべて問題なく動作しますが、カスタム投稿タイプをメニューに追加することはできません(その分類法のためにも)。注:私は以前に知っていた方法と同じくらい多くの方法をチェックしました。 (show_ui、show_in_nav_menus、...)下記は私のCPTのための私のコードです。

<?php
function oseo_custom_post_type() {
    register_taxonomy( 'portfolio_cat', array('oseo_portfolio'),
        array(
            'show_ui'           => true,
            'hierarchical'      => true,
            'label'             => __('Portfolio Filters', 'oseo-portfolio'),
            'singular_label'    => __('portfolio Filter', 'oseo-portfolio'),
            'rewrite'           => array('slug' =>  'portfolio_type')
        )
    );
    $labels = array(
        'name'                => _x( 'Portfolios', 'Post Type General Name', 'oseo-portfolio' ),
        'singular_name'       => _x( 'Portfolio', 'Post Type Singular Name', 'oseo-portfolio' ),
        'menu_name'           => __( 'Portfolios', 'oseo-portfolio' ),
        'parent_item_colon'   => __( 'Parent Portfolio', 'oseo-portfolio' ),
        'all_items'           => __( 'All Portfolios', 'oseo-portfolio' ),
        'view_item'           => __( 'View Portfolio', 'oseo-portfolio' ),
        'add_new_item'        => __( 'Add New Portfolio', 'oseo-portfolio' ),
        'add_new'             => __( 'Add New', 'oseo-portfolio' ),
        'edit_item'           => __( 'Edit Portfolio', 'oseo-portfolio' ),
        'update_item'         => __( 'Update Portfolio', 'oseo-portfolio' ),
        'search_items'        => __( 'Search Portfolio', 'oseo-portfolio' ),
        'not_found'           => __( 'Not Found', 'oseo-portfolio' ),
        'not_found_in_trash'  => __( 'Not found in Trash', 'oseo-portfolio' ),
    );
    $args = array(
        'label'               => __( 'Portfolios', 'oseo-portfolio' ),
        'description'         => __( 'Portfolios', 'oseo-portfolio' ),
        'labels'              => $labels,
        'supports'            => array( 'title', 'editor', 'excerpt', 'thumbnail', 'comments', 'custom-fields', ),
        'taxonomies'          => array( 'portfolio_cat' ),
        'hierarchical'        => true,
        'public'              => true,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'show_in_nav_menus'   => true,
        'show_in_admin_bar'   => true,
        'menu_position'       => 5,
        'can_export'          => true,
        'has_archive'         => true,
        'exclude_from_search' => false,
        'publicly_queryable'  => true,
        'rewrite'   =>  array('slug'    =>  'portfolio'),
        'capability_type'     => 'page',
    );
    flush_rewrite_rules();

    register_post_type( 'oseo_portfolio', $args );

}
add_action( 'init', 'oseo_custom_post_type');
?>

私がこの問題を引き起こすかもしれないと思うもう一つのことは私がこのCPTのためにメタボックスを使うということです。必要に応じて投稿することができます。

1
Ali Qorbani
// portfolio code
function codenovo_portfolio_init(){
    $labels = array(
        'name' => _x('Portfolio', 'post type general name'),
        'singular_name' => _x('Portfolio', 'post type singular name'),
        'add_new' => _x('Add New', 'portfolio'),
        'add_new_item' => __('Add New Portfolio'),
        'edit_item' => __('Edit Portfolio'),
        'new_item' => __('New Portfolio'),
        'view_item' => __('View Portfolio'),
        'search_items' => __('Search Portfolio'),
        'not_found' =>  __('No portfolio found'),
        'not_found_in_trash' => __('No portfolio found in Trash'),
        'parent_item_colon' => '',
        'menu_name' => 'Portfolio'
    );

    $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'query_var' => true,
        'rewrite' => true,
        'capability_type' => 'post',
        'has_archive' => false,
        'hierarchical' => false,
        'menu_position' => null,
        'supports' => array('title','editor','thumbnail'),
        'rewrite' => array(
            'slug'       => 'portfolio',
            'with_front' => FALSE,
        )
    );
    register_post_type('portfolio',$args);

    $labels = array(
        'name' => _x( 'Portfolio Category', 'taxonomy general name' ),
        'singular_name' => _x( 'Category', 'taxonomy singular name' ),
        'search_items' =>  __( 'Search Types' ),
        'all_items' => __( 'All Category' ),
        'parent_item' => __( 'Parent Category' ),
        'parent_item_colon' => __( 'Parent Category:' ),
        'edit_item' => __( 'Edit Category' ),
        'update_item' => __( 'Update Category' ),
        'add_new_item' => __( 'Add New Category' ),
        'new_item_name' => __( 'New Category Name' ),
    );


    register_taxonomy('portfoliocategory',array('portfolio'), array(
        'hierarchical' => true,
        'labels' => $labels,
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => array( 'slug' => 'portifolio_category' ),
    ));


}
add_action('init', 'codenovo_portfolio_init');