Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $query = new WP_Query( array(
- 'post_type' => 'product',
- 'post_status' => 'publish',
- 'posts_per_page' => -1,
- 'tax_query' => array( array(
- 'taxonomy' => 'product_cat',
- 'field' => 'term_id',
- 'terms' => array( get_queried_object()->term_id ),
- ) )
- ) );
- $terms_list = array();
- while ( $query->have_posts() ) : $query->the_post();
- $prd = get_product(get_the_ID());
- $attrs = $prd->get_attributes();
- foreach ( $attrs as $attribute ):
- $attribute_names = $attribute;
- foreach ( $attribute_names["data"]["options"] as $param ) {
- array_push($terms_list, $param);
- }
- // print_r($attribute_names);
- // echo "<pre>"; print_r($attribute_names["data"]["options"]); echo "</pre>";
- endforeach;
- // echo "<pre>"; print_r($attrs); echo "</pre>";
- // echo "<pre>"; print_r($prd); echo "</pre>";
- endwhile;
- $uniq_terms = array_unique($terms_list);
- // print_r($uniq_terms);
- wp_reset_postdata();
- ?>
- // добавить include => $uniq_terms
- <?php $term_query = get_terms(array('taxonomy' =>'pa_color', 'hide_empty' => true, 'include' => $uniq_terms)); foreach ( $term_query as $term ) { ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement