wp_list_pages( $args )
calls get_pages( $args )
. You can filter the get_pages()
output with a filter on get_pages
.
Let’s say you call wp_list_pages()
like this:
wp_list_pages(
array(
'please_filter_me' => TRUE
)
);
You can sort the pages now with code like this (not tested):
add_filter( 'get_pages', function( $pages, $args ) {
// not our query
if ( empty ( $args['please_filter_me'] ) )
return $pages;
$out = $top = array();
foreach ( $pages as $page )
{
if ( get_post_meta( $page->ID, 'my_key', TRUE ) )
$top[] = $page;
else
$out[] = $page;
}
return $top + $out;
}, 10, 2 );