<form action="<?php echo site_url() ?>/wp-admin/admin-ajax.php" method="POST" id="post-date-filter">
<?php
if( $terms = get_terms( 'product_cat', 'orderby=name' ) ) :
foreach ( $terms as $term ) :
echo '<label><input type="checkbox" name="categoryfilter[]" value="' . $term->term_id . '">' . $term->name . '</label>';
endforeach;
endif;
?>
<label>
<input type="radio" name="orderby" value="ASC" /> Price: Ascending
</label>
<label>
<input type="radio" name="orderby" value="DESC" /> Price: Descending
</label>
<button>Применить фильтр</button>
<input type="hidden" name="action" value="customfilter">
</form>
function.php:
function posts_filters(){
if( isset( $_POST['categoryfilter'] ) )
$args['tax_query'] = array(
array(
'taxonomy' => 'product_cat',
'field' => 'id',
'terms' => $_POST['categoryfilter'],
'operator' => 'in'
)
);
if( isset( $_POST['orderby'] ) )
$args['meta_query'][] = array(
'key' => '_price',
'orderby' => 'meta_value_num',
'order' => $_POST['orderby']
);
работают все функции кроме сортировки по цене, что нужно поправить?