简体   繁体   中英

Wordpress Add dropdown in custom post type add/edit post in admin

I am new with wordpress.

i have created three "custom post" type like

  1. Two Wheeler
  2. Three Wheeler
  3. Four Wheeeler

I have used the following code to create custom post type in 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');

Now i want to display Dropdown in admin Add/Edit post of "Two wheeler" custom post type.so user can select that option for that particular post and save that option in database.

Any google link that will help me to do this ?? i Need a way to start work on this.

我不确定我是否完全理解这个问题,但是如果您想为自定义帖子类型添加metabox,则可以查看以下脚本: WPAlchemy MetaBox

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM