Php 吴语商业中特色产品的定制分类
请任何人帮我在woo commerce中仅使用不同的排序属性(如价格、日期)对特色产品进行排序。 我已经试过密码了Php 吴语商业中特色产品的定制分类,php,ajax,wordpress,woocommerce,Php,Ajax,Wordpress,Woocommerce,请任何人帮我在woo commerce中仅使用不同的排序属性(如价格、日期)对特色产品进行排序。 我已经试过密码了 function sort_by() { $args = array( 'post_type' => 'product', 'meta_key' => '_featured', 'meta_value' => 'yes', 'posts_per_page' => '-1', 'order
function sort_by()
{
$args = array(
'post_type' => 'product',
'meta_key' => '_featured',
'meta_value' => 'yes',
'posts_per_page' => '-1',
'orderby' => $_POST['sorter'] ,
'order'=>'ASC'
);
$featured_query = new WP_Query( $args );
print_r($featured_query);
if ($featured_query->have_posts()) :
while ($featured_query->have_posts()) :
$featured_query->the_post();
$product = get_product( $featured_query->post->ID );
echo the_title();
endwhile;
endif;
wp_reset_query(); // Remember to reset
die();
}
add_action('wp_ajax_sort_by','sort_by');
add_action('wp_ajax_no-prev_sort_by','sort_by');
上面的代码在ajax成功时起作用,但它无法根据日期、价格、流行度和评级对功能产品进行排序。价格、流行度和评级是WooCommerce的元键,您必须在$args中使用元查询。阅读谢谢Rahil,我是wordpress的新手,你能描述更多吗。提前谢谢。。