Je suppose qu'il est toujours possible de les masquer avec js, mais existe-t-il un extrait de code pour le filtre de page enfant au niveau de la requête? Je veux seulement que les pages de premier niveau restent.
EDIT: mon codeur est venu avec, restez à l'écoute pour une solution
Cela fonctionne pour nos besoins:
# Parent filtering
function wps_restrict_manage_posts() {
global $typenow;
# only run this filter on page post type
if ( $typenow == 'konverentsid' ) {
# Parent Page Filter (HTML)
$args = array(
'post_type' => 'konverentsid',
'child_of' => 0,
'show_option_none' => __('Show all pages'),
'depth' => 1,
'name' => 'wps_page_filter',
'selected' => $_GET['wps_page_filter'],
);
$dropdown = wp_dropdown_pages( $args );
}
}
add_action ( 'restrict_manage_posts' , 'wps_restrict_manage_posts' );
# Add an option to show top level pages only
add_filter ( 'wp_dropdown_pages' , 'wps_insert_option_in_dropdown' );
function wps_insert_option_in_dropdown ( $output ) {
$filter = $_GET['wps_page_filter'];
if ( $filter == 'parent' )
$selected = ' selected="selected"';
else
$selected = '';
$second_option = __("Show all pages") . '</option><option value="parent"' . $selected . '>' . __("Parent Pages Only") . '</option>';
return preg_replace( '#Show all pages</option>#' , $second_option , $output );
}
add_filter ( 'parse_query', 'wps_admin_posts_filter' );
function wps_admin_posts_filter( $query ) {
global $pagenow;
# Change query based on post_parent
$wps_page_filter = $_GET['wps_page_filter'];
if ( is_admin() && $pagenow == 'edit.php' && !empty( $wps_page_filter ) ) {
if ( $wps_page_filter == 'parent' )
$query->query_vars['post_parent'] = 0;
else
$query->query_vars['post_parent'] = $wps_page_filter;
}
}