Пользовательский тип поста Wordpress, показывающий все посты независимо от типа поста - PullRequest
0 голосов
/ 14 января 2020

У меня есть 2 пользовательских типа сообщений, used-cars и reviews. Когда я открываю обзоры в своей админке, я вижу все сообщения о подержанных автомобилях, почему это должно быть?

Мои подержанные- автомобили CPT инициируется плагином, а отзывы - в моей теме.

Подержанные автомобили

function custom_post_type() {

// Set UI labels for Custom Post Type
    $labels = array(
        'name'                => 'Used Cars',
        'singular_name'       => 'Used Cars',
        'menu_name'           => 'Used Cars',
        'parent_item_colon'   => __( 'Parent Used Cars', 'twentythirteen' ),
        'all_items'           => __( 'All Used Cars', 'twentythirteen' ),
        'view_item'           => __( 'View Used Cars', 'twentythirteen' ),
        'add_new_item'        => __( 'Add New Used Cars', 'twentythirteen' ),
        'add_new'             => __( 'Add New', 'twentythirteen' ),
        'edit_item'           => __( 'Edit Used Cars', 'twentythirteen' ),
        'update_item'         => __( 'Update Used Cars', 'twentythirteen' ),
        'search_items'        => __( 'Search Used Cars', 'twentythirteen' ),
        'not_found'           => __( 'Not Found', 'twentythirteen' ),
        'not_found_in_trash'  => __( 'Not found in Trash', 'twentythirteen' ),
    );

// Set other options for Custom Post Type

    $args = array(
        'label'               => __( 'Used Cars', 'twentythirteen' ),
        'description'         => __( 'Used Cars desc', 'twentythirteen' ),
        'labels'              => $labels,
        // Features this CPT supports in Post Editor
        'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', 'categories' ),
        /* A hierarchical CPT is like Pages and can have
        * Parent and child items. A non-hierarchical CPT
        * is like Posts.
        */ 
        'hierarchical'        => false,
        '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,
        'capability_type'     => 'post',
    );

    // Registering your Custom Post Type
    register_post_type( 'used-cars', $args );

}

/* Hook into the 'init' action so that the function
* Containing our post type registration is not 
* unnecessarily executed. 
*/

add_action( 'init', 'custom_post_type', 0 );

** Отзывы **

add_action( 'init', 'red_post_types_init' );
    function red_post_types_init() {
        register_post_type(
            'review',
            array(
                'labels' => array(
                    'name' => __( 'Reviews', THEME_SLUG ),
                    'singular_name' => __( 'Review', THEME_SLUG ),
                    'add_new' => __( 'Add New', THEME_SLUG ),
                    'add_new_item' => __( 'Add New Review', THEME_SLUG ),
                    'edit' => __( 'Edit', THEME_SLUG ),
                    'edit_item' => __( 'Edit Review', THEME_SLUG ),
                    'new_item' => __( 'New Review', THEME_SLUG ),
                    'view' => __( 'View Reviews', THEME_SLUG ),
                    'view_item' => __( 'View Review', THEME_SLUG ),
                    'search_items' => __( 'Search reviews', THEME_SLUG ),
                    'not_found' => __( 'Not found', THEME_SLUG ),
                    'not_found_in_trash' => __( 'Not found in Trash', THEME_SLUG ),
                ),
                'description' => __( 'Customer reviews and testimonials.', THEME_SLUG ),
                'public' => true,
                'has_archive' => true,
                'menu_icon' => 'dashicons-star-filled',
                /*
                'rewrite' => array(
                    'slug' => 'case-study',
                ),
                */
                'supports' => array(
                    'title',
                    'editor',
                    'thumbnail',
                    'page-attributes',
                    'revisions'
                ),

                'capability_type'     => 'post',
            )
        );
    }


// Register Menus
    function red_register_menus() {
      register_nav_menus(
        array(
          'main-menu' => __( 'Main Menu' ),
          'footer-menu' => __( 'Footer Menu' ),
        )
      );
    }
    add_action( 'init', 'red_register_menus' );

Может кто-нибудь объяснить мне, почему в wp-admin я бы видел подержанные автомобили в посте отзывов?

...