Order listings by custom metadata
Hi! We're using the Vantage theme, and have added custom fields to our listings using the Custom Form tool. Each listing now has a "first name" and a "last name". (The title is a company name.) Is it possible to sort listings in search results by this last name metadata? We're currently using a child theme to modify Vantage.
I'm familiar with the process of using WP_Query to sort post output using metadata, for example:
$query = new WP_Query( array ( 'post_type' => 'listing', 'orderby' => 'meta_value', 'meta_key' => 'app_lastname', ', 'order' => 'ASC' ) );
But I'm not sure where I can adjust the post query in the child theme to get the results we're looking for. Any suggestions would be appreciated. Thanks!