The Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | $args = array( 'post_status' => 'publish' 'post_type' => 'board', 'meta_query' => array( 'last_name' => array( 'key' => 'last_name' ), 'first_name' => array( 'key' => 'first_name' ), ), 'orderby' => array( 'last_name' => 'ASC', 'first_name' => 'ASC' ), 'nopaging' => true ); $query = new WP_Query( $args ); if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); |
Always call
1 | wp_reset_postdata() |
afterwards to reset the global $post value. Otherwise, any attempt to retrieve data from the page will return null.