У меня ...
1 - каждый из нескольких тегов HTML имеет свой атрибут id.
<a href="#" name="term_id" class="cat_image" id="1">
<a href="#" name="term_id" class="cat_image" id="2">
<a href="#" name="term_id" class="cat_image" id="3">
<a href="#" name="term_id" class="cat_image" id="4">
2 - Функция WordPress для получения идентификатора и присвоения ему tax_queryмассив -> условия в качестве идентификатора
$args = array(
'numberposts' => -1,
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'term_id',
'terms' => ** the id goes here **,
'operator' => 'IN'
)),
'post_type' => 'product',
'orderby' => 'author',
'order' => 'ASC',
'post_status' => 'publish'
);
$cat_posts = get_posts($args);
Когда пользователь щелкает тег, я хочу назначить этот клик-идентификатор массиву tax_query ...
Затем я хочу отобразить эту категориюсообщения с использованием ajax.
Пока я здесь
jQuery('.cat_image').click(function(){
jQuery.ajax({
url:"/wp-admin/admin-ajax.php",
data:jQuery(this).attr("id"),
type:"POST", // POST
beforeSend:function(xhr){
console.log('Processing...');
},
success:function(data){
console.log('success');
}
})//ajax ends here;
return false;
});