我有一个自定义的帖子类型事件。我还有自定义元框(例如该事件发言人的下拉列表)。但是,扬声器列表由我硬编码,客户希望能够从管理员部分添加,编辑和删除扬声器。
我该怎么做?
答案 0 :(得分:1)
$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>
答案 1 :(得分:0)
你可以通过自定义元数据来实现,这里是代码格式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
)
);