Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <select>
- <option>post title n°1<option>
- <option>post title n°2<option>
- ....
- </select>
- function generate_post_select($select_id, $post_type, $selected = 0) {
- $post_type_object = get_post_type_object($post_type);
- $label = $post_type_object->label;
- $posts = get_posts(array('post_type'=> $post_type, 'post_status'=> 'publish', 'suppress_filters' => false, 'posts_per_page'=>-1));
- echo '<select name="'. $select_id .'" id="'.$select_id.'">';
- echo '<option value = "" >All '.$label.' </option>';
- foreach ($posts as $post) {
- echo '<option value="', $post->ID, '"', $selected == $post->ID ? ' selected="selected"' : '', '>', $post->post_title, '</option>';
- }
- echo '</select>';
- }
- wp_dropdown_pages(array('post_type'=>'video'));
- wp_dropdown_categories();
- wp_dropdown_categories('taxonomy=your_texonomy&hide_empty=0&orderby=name&name=types&show_option_none=Select type);
- add_action('restrict_manage_posts', function () {
- $args = [
- 'post_type' => 'your_custom_post_type',
- ];
- wp_dropdown_pages($args);
- });
Add Comment
Please, Sign In to add comment