Code Samples /

Ordering by Multiple Fields

Ajax Load More supports a single orderby parameter, however, the WP_Query class allows for ordering by multiple parameters. By using the alm_query_args filter you can extend the Ajax Load More query to order posts by multiple parameters.

functions.php
<?php 
function my_movie_listing( $args, $id ){ 
   // [ajax_load_more id="movie_listing" meta_key="order"] 
   $args['orderby'] = array(
      'meta_value_num' => 'ASC',
      'title' => 'DESC'
   );
   return $args; 
}
add_filter( 'alm_query_args_movie_listing', 'my_movie_listing', 10, 2 );
PHP

« Back to Code Samples