parse_query filter changed in 3.1 ?
-
in previous versions of WP (3.0.5), i had been able to list all Pages with a given Page Template (meta_key _wp_page_template = “mytemplate.php”) by adding a filter to the “parse_query” . the following code in my theme’s functions.php made it so the link /wp-admin/edit.php?s&post_type=page&mypagetemplate=mytemplate.php showed the EDIT PAGES screen, listing only Pages where the _wp_page_template = “mytemplate.php”
add_filter( 'parse_query', 'my_pagetemplate_filter' ); function my_pagetemplate_filter( $query ) { global $pagenow; if ( is_admin() && $pagenow == 'edit.php' && isset( $_GET['post_type'] ) && isset( $_GET['post_type'] ) == 'page' && isset( $_GET['mypagetemplate'] ) && isset( $_GET['mypagetemplate'] ) == 'mytemplate.php' ) { $query->query_vars['orderby'] = 'meta_value'; $query->query_vars['meta_key'] = '_wp_page_template'; $query->query_vars['meta_value'] = 'mytemplate.php'; } }
However, with the upgrade to 3.1, that no longer works, and the same link now just returns “No pages found.”
Can anyone provide insight as to what has changed on the $query level, if this is still possible with WP 3.1, or if I should just forget that it ever was possible?
- The topic ‘parse_query filter changed in 3.1 ?’ is closed to new replies.