簡體   English   中英

自定義帖子類型中的WordPress添加下拉列表在admin中添加/編輯帖子

[英]Wordpress Add dropdown in custom post type add/edit post in admin

我是wordpress新手。

我創建了三種“自定義帖子”類型

  1. 兩輪車
  2. 三輪車
  3. 四胡

我已使用以下代碼在admin中創建自定義帖子類型。

function create_post_type_two_wheeler()
{
    register_taxonomy_for_object_type('category', 'TwoWheeler'); // Register Taxonomies for Category
    register_taxonomy_for_object_type('post_tag', 'TwoWheeler');
    register_post_type('client', // Register Custom Post Type
        array(
            'labels' => array(
                'name' => __('TwoWheeler', 'vehicles'), // Rename these to suit
                'singular_name' => __('TwoWheeler', 'vehicles'),
                'add_new' => __('Add New', 'vehicles'),
                'add_new_item' => __('Add New TwoWheeler', 'vehicles'),
                'edit' => __('Edit', 'vehicles'),
                'edit_item' => __('Edit TwoWheeler', 'vehicles'),
                'new_item' => __('New TwoWheeler', 'vehicles'),
                'view' => __('View TwoWheeler', 'vehicles'),
                'view_item' => __('View TwoWheeler', 'vehicles'),
                'search_items' => __('Search TwoWheeler', 'vehicles'),
                'not_found' => __('No TwoWheeler found', 'vehicles'),
                'not_found_in_trash' => __('No TwoWheeler found in Trash', 'vehicles')
            ),
            'public' => true,
            'hierarchical' => true, // Allows your posts to behave like Hierarchy Pages
            'has_archive' => true,
            'supports' => array(
                'title',
                'editor',
                'excerpt',
                'thumbnail'
            ), // Go to Dashboard Custom HTML5 Blank post for supports
            'can_export' => true, // Allows export in Tools > Export
            'taxonomies' => array(
                'post_tag',
                'category'
            ) // Add Category and Post Tags support
        ));

}

add_action('init', 'create_post_type_two_wheeler');

現在我想在“兩輪車”自定義帖子類型的管理員添加/編輯帖子中顯示下拉列表。因此用戶可以為該特定帖子選擇該選項,並將該選項保存在數據庫中。

任何谷歌鏈接,將幫助我做到這一點? 我需要一種方法來開始這項工作。

我不確定我是否完全理解這個問題,但是如果您想為自定義帖子類型添加metabox,則可以查看以下腳本: WPAlchemy MetaBox

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM