Guest User

Untitled

a guest
Dec 13th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. <select>
  2. <option>post title n°1<option>
  3. <option>post title n°2<option>
  4. ....
  5. </select>
  6.  
  7. function generate_post_select($select_id, $post_type, $selected = 0) {
  8. $post_type_object = get_post_type_object($post_type);
  9. $label = $post_type_object->label;
  10. $posts = get_posts(array('post_type'=> $post_type, 'post_status'=> 'publish', 'suppress_filters' => false, 'posts_per_page'=>-1));
  11. echo '<select name="'. $select_id .'" id="'.$select_id.'">';
  12. echo '<option value = "" >All '.$label.' </option>';
  13. foreach ($posts as $post) {
  14. echo '<option value="', $post->ID, '"', $selected == $post->ID ? ' selected="selected"' : '', '>', $post->post_title, '</option>';
  15. }
  16. echo '</select>';
  17. }
  18.  
  19. wp_dropdown_pages(array('post_type'=>'video'));
  20.  
  21. wp_dropdown_categories();
  22.  
  23. wp_dropdown_categories('taxonomy=your_texonomy&hide_empty=0&orderby=name&name=types&show_option_none=Select type);
  24.  
  25. add_action('restrict_manage_posts', function () {
  26.  
  27. $args = [
  28. 'post_type' => 'your_custom_post_type',
  29. ];
  30.  
  31. wp_dropdown_pages($args);
  32.  
  33. });
Add Comment
Please, Sign In to add comment