On the admin Pages screen (edit.php) I'm adding the following filter to only show a certain taxonomy for certain users.
The problem is this doesn't list out the pages in the same order as the default page ordering. For example this is how the pages show without my taxonomy filter:
- Parent1 (menu_order: 4)
-
- Child 1-1 (menu_order:0)
- Parent2 (menu_order: 5)
-
- Child 2-1 (menu_order:0)
-
- Child 2-1 (menu_order:1)
And this is how the pages show with my taxonomy filter:
-
- Child 1-1 (menu_order:0)
-
- Child 2-1 (menu_order:0)
-
- Child 2-1 (menu_order:1)
- Parent1 (menu_order: 4)
- Parent2 (menu_order: 5)
Understandably it is ordering by menu_order but it is ignoring the hierarchy. This different ordering only occurs when I set the tax_query. Is there any way to set the tax_query but still have it ordered as in the first example?
I have simplified my code to the following:
if ( $pagenow == 'edit.php' )
add_filter( 'pre_get_posts', 'my_posts_query' );
function my_posts_query( $query ){
$taxquery = array(
array(
'taxonomy' => $taxonomy,
'field' => 'id',
'terms' => $ids
)
);
$query->set( 'tax_query', $taxquery );
$query->set( 'orderby', 'menu_order title' );
$query->set( 'order', 'ASC' );</li>
return $query;
}