Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function parse_query( $query ) {
- global $pagenow;
- // Change query based on post_parent
- $parent_filter = $_GET['parent'];
- if ( is_admin() && $pagenow == 'edit.php' && ! empty( $parent_filter ) ) {
- $query->query_vars['post_parent'] = (int) $parent_filter;
- }
- }
- public static function restrict_manage_posts() {
- if ( isset( $_GET['post_type'] ) && $_GET['post_type'] == 'episode' ) {
- $args = [
- 'post_type' => 'podcast',
- 'numberposts' => - 1,
- ];
- $podcasts = get_posts( $args );
- $select = '<select name="parent"><option value="">Podcast (' . count( $podcasts ) . ')</option>';
- foreach ( $podcasts as $podcast ) {
- $selected = ( isset( $_GET['parent'] ) && (int) $_GET['parent'] > 0 ) ? 'selected="selected"' : '';
- $select .= '<option value="' . $podcast->ID . '" ' . $selected . '>' . $podcast->post_title . '</option>';
- }
- $select .= '</select>';
- echo $select;
- } else {
- return;
- }
- }
Add Comment
Please, Sign In to add comment