I’ve a customized submit sort location which has completely different classes (e.g. museums, theatres, purchasing) and I need to output every of those classes and order inside these classes by distance which is a customized meta discipline. Proper now, I’ve following code, however can’t make the ordering work by distance.
<?php
$custom_terms = get_terms('location_category');
foreach($custom_terms as $custom_term) {
wp_reset_query();
$args = array('post_type' => 'location',
'tax_query' => array(
array(
'taxonomy' => 'location_category',
'discipline' => 'slug',
'phrases' => $custom_term->slug,
),
),
);
$loop = new WP_Query($args);
if($loop->have_posts()) {;?>
In the meanwhile, I am utilizing usort to order alphabetically (see under), however this must be modified to ordering by distance.
<?php usort($loop->posts, perform($a, $b) {
return strcasecmp(
$a->post_title,
$b->post_title
);
});?>
Can anybody please assist me with this?