Here is my code:
$args = array(
'posts_per_page' => - 1,
'post_type' => array('post-type-name'),
'tax_query' => $taxquery,
'orderby' => 'meta_value_num',
'meta_key' => 'date_of_issue',
'order' => 'DESC',
);
global $post;
$post_list = get_posts($args);
if ($post_list) {
foreach ($post_list as $post_item) { ?>
<?php
$fields = CFS()->get('anouncements', $post_item->ID);
if ( ! empty ( $fields ) ){
foreach ($fields as $field_eti) { ?>
<div class="item"><?php echo $field_eti['date_of_issue']; ?></div>
<?php }
}
?>
<?php
}
}
I’m using Custom Field suite plugin. I want to order those fields by this date which is one of the custom fields of that loop ($field_eti['date_of_issue'];
). How you see in my $args I added that meta_key and ordered it by custom field value which is date. But ordering isn’t right.
Try this: I have updated my answer.