In the template for the sidebar, a selection is made of the categories of goods specified in the plugin, and it is necessary to implement a further selection of its fields for these categories. With this moment stuck, I ask for help. template:
<ul class="collapsible" data-collapsible="accordion"> <!--парсим категории в магазине--> <?php $taxonomy = 'product_cat'; $orderby = 'name'; $show_count = 0; $pad_counts = 0; $hierarchical = 0; $title = ''; $empty = 0; $args = array( 'taxonomy' => $taxonomy, 'orderby' => $orderby, 'show_count' => $show_count, 'pad_counts' => $pad_counts, 'hierarchical' => $hierarchical, 'title_li' => $title, 'hide_empty' => $empty ); $all_categories = get_categories( $args ); foreach ($all_categories as $cat) { $category_id = $cat->term_id; ?> <!--и делаем их ссылками--> <li> <div class="collapsible-header"> <p class="openSemi black-text"> <?php echo $cat->name ?> </p> <div class="triangle-cover hide"></div> <div class="triangle hide"></div> </div> <div class="collapsible-body"> <?php $goodsArgs = array( // тут указываем его тип 'post_type' => 'product', 'product_cat' => $cat->name, 'hide_empty' => 0, 'post_per_page' => 1 ); $i=0; // запускаем $wc_query = new WP_Query( $goodsArgs ); while ($wc_query->have_posts()) : $wc_query->the_post(); global $product; $mans = get_the_terms( $product->id, 'pa_manufacturer'); // тут вот категории должны бы превращаться в чекбоксы для дальнейшей обработки, но не превращаются foreach($mans as $manufacturer) { ?> <p class="exo2Medium black-text"> <input type="checkbox" id="<?php echo 'manufacturer ' . $i; ?>" /> <label class="exo2Medium black-text" for="<?php echo 'manufacturer ' . $i; ?>"> <?php echo $manufacturer->name; ?> </label> </p> <?php $i++; }; endwhile; wp_reset_postdata(); ?> </div> </li> <? } wp_reset_query(); ?> </ul> Already tried:
An analogue of the current code on the native function for the vocational school was also tried, the result is the same - the attributes (manufacturer) are displayed only for the inserted goods:
<?php $goodsArgs = array( 'post_type' => 'product', 'product_cat' => $cat->name, 'hide_empty' => 0, 'post_per_page' => 1 ); $i=0; $wc_query = new WP_Query( $goodsArgs ); while ($wc_query->have_posts()) : $wc_query->the_post(); global $product; $mans = wc_get_product_terms( $post->ID, 'pa_manufacturer', false ); foreach($mans as $manufacturer) { ?> <p class="exo2Medium black-text"> <input type="checkbox" id="<?php echo 'manufacturer ' . $i; ?>" /> <label class="exo2Medium black-text" for="<?php echo 'manufacturer ' . $i; ?>"> <?php echo $manufacturer; ?> </label> </p> <?php $i++; }; endwhile; wp_reset_postdata(); ?> </div> </li> <? } wp_reset_query(); ?> and another option:
$mans = get_terms("pa_manufacturer"); $i = 0; foreach($mans as $manufacturer) { ?> <p class="exo2Medium black-text"> <input type="checkbox" id="<?php echo 'manufacturer ' . $i; ?>" /> <label class="exo2Medium black-text" for="<?php echo 'manufacturer ' . $i; ?>"> <?php echo $manufacturer->name; ?> </label> </p> <?php $i++; }; Deduced attributes for the goods hammered in an admin panel, but already without definition of a category, did not fit.
What am I missing? I would be grateful for the help / direction in the necessary mana. Thank.