Reputation: 116
I have a custom post type Event. I also have custom meta boxes (e.g. a dropdown list for the speaker of that event). However, the list of speakers are hard coded by me, and the client wants to be able to add, edit, and remove the speakers from the admin part.
How do I do this?
Upvotes: 0
Views: 657
Reputation: 3358
you can do it by custom metabox, here is the code form codex
register_taxonomy(
'speakers',
array( 'YOUR_POST_TYPE' ),
array(
'hierarchical' => true,
'labels' => array(
'name' => _x( 'Speakers', 'taxonomy general name' ),
'singular_name' => _x( 'Speaker', 'taxonomy singular name' ),
'search_items' => __( 'Search Speakers' ),
'all_items' => __( 'All Speakers' ),
'parent_item' => __( 'Parent Speakers' ),
'parent_item_colon' => __( 'Parent Speakers:' ),
'edit_item' => __( 'Edit Speakers' ),
'update_item' => __( 'Update Speakers' ),
'add_new_item' => __( 'Add New Speakers' ),
'new_item_name' => __( 'New SpeakersName' ),
'menu_name' => __( 'Speakers' ),
),
'rewrite' => true
)
);
Upvotes: 0
Reputation: 3648
$items = get_posts( array (
'post_type' => YOUR_POST_TYPE,
'posts_per_page' => -1,
'post_status' => 'publish'
));
<select name="get-posts" id="get-posts">
<option value="">Choose A Page</option>
<?php
foreach($items as $item) {
echo '<option value="'.$item->ID.'"',$meta == $item->ID ? ' selected="selected"' : '','>'.$item->post_title.'</option>';
} // end foreach ?>
</select>
Upvotes: 1