30. Tìm hiểu kỹ hơn về change_query (ok)
C:\xampp\htdocs\test\wp-content\plugins\plugin-name\public\class-wpf-public_ct.php
Không ghi đè var trống và có giá trị mặc định
public function change_query( $query ) {
if ( $form = $this->get_form( sanitize_key( $_GET['wpf_ct'] ) ) ) {
$args = $this->parse_query( $_GET, $form );
echo '<pre>';
foreach ( $args as $k => $v ) {
// Don't override the var that is empty and has default value #8913
if(empty($args[$k]) && !empty($query->get($k))){
continue;
}
$query->set( $k, $v );
}
echo '</pre>';
}
}1.
echo '<pre>';
var_export($args);
echo '</pre>';array (
'post_type' => 'product',
'post_status' => 'publish',
'is_paginated' => 1,
'meta_query' =>
array (
),
'tax_query' =>
array (
0 =>
array (
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' =>
array (
0 => 'decor',
),
'operator' => 'IN',
'include_children' => true,
),
'relation' => 'or',
),
'post__not_in' =>
array (
),
'posts_per_page' => '10',
'paged' => 1,
'offset' => 0,
'orderby' => 'menu_order title',
'order' => 'asc',
)2.
3.
Previous29. Source dự trữ đã viết xong lọc category (ok)Next======== End Nghiên cứu plugin Themify-wc-product-filter ======
Last updated
Was this helpful?