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'
));
?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.