Support

Account

Home Forums Add-ons Repeater Field Order by Custom Field While Using a Post Object within Repeater Filed Reply To: Order by Custom Field While Using a Post Object within Repeater Filed

  • Hi @chriswhiteley,

    You can make use of the the WP_Query object to load all the posts ordered by a custom field in your case based on the last_name field:

    The code will look something like this:

    <?php 
    
    // query
    $the_query = new WP_Query(array(
    	'post_type'			=> 'post_type_name',
    	'posts_per_page'	        => -1,
    	'meta_key'			=> 'last_name',
    	'orderby'			=> 'meta_value_num',
    	'order'				=> 'ASC'
    ));
    ?>