Title: get a custom attribute value within loop
Last modified: January 30, 2017

---

# get a custom attribute value within loop

 *  Resolved [spirit1nfernal](https://wordpress.org/support/users/spirit1nfernal/)
 * (@spirit1nfernal)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/get-a-custom-attribute-value-within-loop/)
 * Could anyone help with retrieving full list of added custom attributes from WC
   plugin within a loop, which gets product categories?
 * Now doing following:
 *     ```
       <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>
       ```
   
 * As expects all above must throw out front-end a dropdown list with categories
   of products (two categories with checkboxes, which contains custom attributes
   for each category (didn’t found better way to store manufaturers). But it show
   only both categories and one product manufaturer, who linked to already added
   product.
 * What already tried to do: tried to use custom loop from native wordpress wp_query
   function – gives strange result, when manufacturer, who have added product lists
   three times for one category; tried didn’t specify conditions, then munfacturer
   who have added product – shows for both different categories, and products already
   added is added only into one of them.
 * I understand, that I doing something wrong, but can’t understand, where is hidden
   my mistake. Please, help me find it. Thanks

The topic ‘get a custom attribute value within loop’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [custom attributes](https://wordpress.org/support/topic-tag/custom-attributes/)
 * [wooommerce](https://wordpress.org/support/topic-tag/wooommerce/)

 * 0 replies
 * 1 participant
 * Last reply from: [spirit1nfernal](https://wordpress.org/support/users/spirit1nfernal/)
 * Last activity: [9 years, 4 months ago](https://wordpress.org/support/topic/get-a-custom-attribute-value-within-loop/)
 * Status: resolved