Is there a smart way to order an array by the acf radio button values? I have a top-page page-template, and a couple of child pages with custom fields.
In the top-page i want to display some values from the child pages: page title, and some values from the child pages acf fields And finally i want to order the array by the acf radio button values.
The radio button values is:
one : A
two : B
three : C
four : D
five : E
The field is mandatory so i don't have to test to see if there is a value.
<section id="info-box">
<?php
if(function_exists( 'get_field') ){
$query = new WP_Query( 'pagename=top-page' );
$services_id = $query->queried_object->ID;
wp_reset_postdata(); //* Restore original Post Data *//
$args = array(
'posts_per_page' => -1,
'post_type' => 'page',
'post_parent' => $services_id,
'orderby' => '', // radio button value //
'order' => 'ASC'
);
$services_query = new WP_Query( $args );
// The Loop
if ( $services_query->have_posts() ) {
echo '<ul class="info-box-list">';
while ( $services_query->have_posts() ) {
$services_query->the_post();
echo '<li class="list-item">';
echo '<div class="list-item-box">';
echo '<a href="' . get_permalink() . '" figure class="link-box-image">';
the_field('image');
echo '</figure>';
echo '</a>';
echo get_the_title();
the_field( 'sub-title' );
echo '</div>';
echo '</li>';
}
echo '</ul>';
}
/* Restore original Post Data */
wp_reset_postdata();
}
?>
</section>
Right now I'm kinda just dumping the fields onto the top-page until i can figure out if there is a smart way to order the list by the radio button value, the acf documentation is not that good on the radio buttons functionality.