Guest User

Untitled

a guest
Dec 13th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. function parse_query( $query ) {
  2. global $pagenow;
  3. // Change query based on post_parent
  4. $parent_filter = $_GET['parent'];
  5. if ( is_admin() && $pagenow == 'edit.php' && ! empty( $parent_filter ) ) {
  6. $query->query_vars['post_parent'] = (int) $parent_filter;
  7. }
  8. }
  9.  
  10. public static function restrict_manage_posts() {
  11.  
  12. if ( isset( $_GET['post_type'] ) && $_GET['post_type'] == 'episode' ) {
  13. $args = [
  14. 'post_type' => 'podcast',
  15. 'numberposts' => - 1,
  16. ];
  17. $podcasts = get_posts( $args );
  18.  
  19. $select = '<select name="parent"><option value="">Podcast (' . count( $podcasts ) . ')</option>';
  20. foreach ( $podcasts as $podcast ) {
  21. $selected = ( isset( $_GET['parent'] ) && (int) $_GET['parent'] > 0 ) ? 'selected="selected"' : '';
  22. $select .= '<option value="' . $podcast->ID . '" ' . $selected . '>' . $podcast->post_title . '</option>';
  23. }
  24. $select .= '</select>';
  25. echo $select;
  26. } else {
  27. return;
  28. }
  29. }
Add Comment
Please, Sign In to add comment