Home › Forums › Add-ons › Repeater Field › Echo Repeater-Field alphabetically query_posts › Reply To: Echo Repeater-Field alphabetically query_posts
Hi @rhodesign
This is what I can come up with:
// find todays date
$today = date('Ymd');
$args = array(
'numberposts' => -1,
'post_type' => 'test',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'date',
'value' => $today,
'compare' => '<',
),
)
);
$the_query = new WP_Query( $args );
$post_ids = wp_list_pluck( $the_query->posts, 'ID' );
$artist_list = array();
foreach($post_ids as $post_id){
$artist_repeater = get_field('artists', $post_id);
foreach($artist_repeater as $artist_detail){
array_push($artist_list, $artist_detail);
}
}
$artist_list = array_map("unserialize", array_unique(array_map("serialize", $artist_list)));
$order = array();
foreach( $artist_list as $i => $row ) {
$order[ $i ] = $row['artistname'];
}
array_multisort( $order, SORT_ASC, $artist_list );
echo "<pre>";
print_r($artist_list);
echo "</pre>";
This code will list the artists name and websites in an array. It’s more of a PHP issue, so If you don’t understand it, please ask in the PHP forum or hire a developer to help you out with it.
I hope this helps.
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.