2017-08-02 23 views
0

我用php創建了自定義帖子類型,我的問題是此帖子類型沒有出現在工具集類型插件的菜單中。我認爲這必須是我必須填補的一些選擇,但我已經嘗試了幾乎所有的東西,我不知道爲什麼會發生這種情況。在工具集類型插件上顯示自定義帖子類型

我想編輯帖子類型之間的關係,特別是汽車和新聞之間的關係。

我的代碼來創建自定義帖子類型是這樣的。

function car_post_type() { 
    $labels = array(
     'name' => 'Coches', 
     'singular_name' => 'Coche', 
     'menu_name' => 'Coches', 
     'name_admin_bar' => 'Coches', 
     'parent_item_colon' => 'Padre:', 
     'all_items' => 'Todos los coches', 
     'add_new_item' => 'Añadir nuevo coche', 
     'add_new' => 'Añadir coche', 
     'new_item' => 'Nuevo coche', 
     'edit_item' => 'Editar coche', 
     'update_item' => 'Actualizar coche', 
     'view_item' => 'Ver coche', 
     'search_items' => 'Buscar coches', 
     'not_found' => 'No hay resultados', 
     'not_found_in_trash' => 'No se han encontrado coches en la papelera', 
    ); 
    $rewrite = array(
     'slug' => 'coche', 
     'with_front' => true, 
     'pages' => true, 
     'feeds' => true, 
    ); 
    $args = array(
     'label' => __('Car', 'clever'), 
     'description' => __('Cars', 'clever'), 
     'labels' => $labels, 
     'supports' => array(
      'title', 'editor', 'excerpt', 'thumbnail', 'revisions', 
     ), 
     'taxonomies' => array(), 
     'hierarchical' => false, 
     'public' => true, 
     'show_ui' => true, 
     'show_in_menu' => true, 
     'menu_position' => 5, 
     'menu_icon' => 'dashicons-dashboard', 
     'show_in_admin_bar' => true, 
     'show_in_nav_menus' => true, 
     'can_export' => true, 
     'has_archive' => true, 
     'exclude_from_search' => false, 
     'publicly_queryable' => true, 
     'rewrite' => $rewrite, 
     'capability_type' => 'post', 
    ); 

    register_post_type('car', $args); 
} 
add_action('init', 'car_post_type', 0); 

感謝您的幫助。

回答

0

我已經找到了ACF插件的解決方案,這個插件允許在使用php創建一個帖子類型時創建帖子類型之間的關係。

你可以從這裏下載該插件:

https://www.advancedcustomfields.com/

相關問題