register_post_type() not show menu in admin.
-
I put all the fields of register_post_type into the database, and then through the foreach stored multiple arrays, the results of my custom post type can not show in the admin.
add_action( 'init', array( $this, 'tn_init' ), 99 ); public function tn_init() { // Load WP custom post type new \Trueniu\Post\PostInit(); } <?php namespace Trueniu\Post; class PostInit { public function __construct() { $tnPostType = get_option( 'tn_post_options' ); if ( isset( $tnPostType ) && !empty( $tnPostType ) ) { foreach ( $tnPostType as $val ) { if ( isset( $val['status'] ) && $val['status'] ) { $labels = array( 'name' => $val['plural_name'], 'singular_name' => $val['singular_name'], 'menu_name' => __( $val['menu_name'], 'trueniu-init' ), 'name_admin_bar' => __( $val['name_admin_bar'], 'trueniu-init' ), 'archives' => __( $val['archives'], 'trueniu-init' ), 'attributes' => __( $val['attributes'], 'trueniu-init' ), 'parent_item_colon' => __( $val['parent_item_colon'], 'trueniu-init' ), 'all_items' => __( $val['all_items'], 'trueniu-init' ), 'add_new_item' => __( $val['add_new_item'], 'trueniu-init' ), 'add_new' => __( $val['add_new'], 'trueniu-init' ), 'new_item' => __( $val['new_item'], 'trueniu-init' ), 'edit_item' => __( $val['edit_item'], 'trueniu-init' ), 'update_item' => __( $val['update_item'], 'trueniu-init' ), 'view_item' => __( $val['view_item'], 'trueniu-init' ), 'view_items' => __( $val['view_items'], 'trueniu-init' ), 'search_items' => __( $val['search_items'], 'trueniu-init' ), 'not_found' => __( $val['not_found'], 'trueniu-init' ), 'not_found_in_trash' => __( $val['not_found_in_trash'], 'trueniu-init' ), 'featured_image' => __( $val['featured_image'], 'trueniu-init' ), 'set_featured_image' => __( $val['set_featured_image'], 'trueniu-init' ), 'remove_featured_image' => __( $val['remove_featured_image'], 'trueniu-init' ), 'use_featured_image' => __( $val['use_featured_image'], 'trueniu-init' ), 'insert_into_item' => __( $val['insert_into_item'], 'trueniu-init' ), 'uploaded_to_this_item' => __( $val['uploaded_to_this_item'], 'trueniu-init' ), 'items_list' => __( $val['items_list'], 'trueniu-init' ), 'items_list_navigation' => __( $val['items_list_navigation'], 'trueniu-init' ), 'filter_items_list' => __( $val['filter_items_list'], 'trueniu-init' ), ); $args = array( 'label' => $val['singular_name'], 'description' => $val['description'], 'labels' => $labels, 'supports' => $val['supports'], 'taxonomies' => explode( ',', $val['taxonomies'] ), 'hierarchical' => false, 'public' => $val['public'] == '1' ? 'true' : 'false', 'show_ui' => $val['show_ui'] == '1' ? 'true' : 'false', 'show_in_menu' => $val['show_in_menu'] == '1' ? 'true' : 'false', 'menu_position' => $val['menu_position'], 'menu_icon' => $val['menu_icon'], 'show_in_admin_bar' => $val['show_in_admin_bar'] == '1' ? 'true' : 'false', 'show_in_nav_menus' => $val['show_in_nav_menus'] == '1' ? 'true' : 'false', 'can_export' => $val['can_export'] == '1' ? 'true' : 'false', 'has_archive' => $val['has_archive'] == '1' ? 'true' : 'false', 'exclude_from_search' => $val['exclude_from_search'] == '1' ? 'true' : 'false', 'publicly_queryable' => true, 'query_var' => true, 'capability_type' => $val['capability_type'], ); register_post_type( $val['post_type'], $args ); } } } } }
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘register_post_type() not show menu in admin.’ is closed to new replies.