вот кусок из functions.php
function get_ajax_posts()
{
$args = array(
'post_status' => array('publish'),
'date_query' => array(
array(
'year' => $_POST['year'],
'month' => $_POST['monyj'], // обратите внимание, раньше было monthnum, теперь просто month
),
),
);
$ajaxposts = new WP_Query($args);
$response = '';
if ($ajaxposts->have_posts()) {
while ($ajaxposts->have_posts()) {
$ajaxposts->the_post();
$response .= get_template_part('product_template');
}
} else {
$response .= get_template_part('none');
}
echo $response;
exit;
}
add_action('wp_ajax_get_ajax_posts', 'get_ajax_posts');
add_action('wp_ajax_nopriv_get_ajax_posts', 'get_ajax_posts');
$.ajax({
type: 'POST',
url: '/wp-admin/admin-ajax.php',
dataType: "html",
data: {
action : 'get_ajax_posts',
weight: $("select.weight.select-hidden").val(),
weight_hidden: $(".weight ~ .select-options li:nth-child(2)").attr("rel"),
taste: $("select.taste.select-hidden").val(),
taste_hidden: $(".taste ~ .select-options li:nth-child(2)").attr("rel"),
odrer_price: order,
},
success: function( data ) {
$( '.prods_row' ).html( data );
}
});
$("a.button_close.filter_reset, .load_all_products").on("click", function () {
$.ajax({
type: 'POST',
url: '/wp-admin/admin-ajax.php',
dataType: "html",
data: {
action : 'get_all_products',
},
success: function( data ) {
$(".select-hidden").each(function () {
$(this).parent().find(".select-styled").text($(this).parent().find(".select-options li:first-child").text());
$(this).removeClass("error_select");
});
$(".load_all_products").hide();
$( '.prods_row' ).html( data );
}
});
})
function get_all_products() {
// Query Arguments
$args = array(
'post_type' => array('product'),
'post_status' => array('publish'),
'orderby' => 'meta_value_num',
'meta_key' => '_price',
'order' => "DESC"
);
// The Query
$ajaxposts = new WP_Query( $args );
$response = '';
// The Query
if ( $ajaxposts->have_posts() ) {
while ( $ajaxposts->have_posts() ) {
$ajaxposts->the_post();
$response .= get_template_part('product_template');
}
} else {
$response .= get_template_part('none');
}
echo $response;
exit; // leave ajax call
}
// Fire AJAX action for both logged in and non-logged in users
add_action('wp_ajax_get_all_products', 'get_all_products');
add_action('wp_ajax_nopriv_get_all_products', 'get_all_products');
$services_id = get_cat_ID( 'services' );
foreach( $categories as $category ) {
if( 0 != $category->parent && $category->category_parent != $services_id
&& $category->cat_ID != $services_id ) {
if($category->cat_name!==""){
echo '<button>';
echo $category->cat_name . '</button>';
}else{
echo '<button class="subcat_link">';
echo $category->cat_name . '</button>';
}
}
}