0

I am making a custom loop for my site using Woocommerce, I am using sub categories as a additional text field for the products but I can't find a function to just show sub categories, all are showing main and sub categories.

Can anyone help ?

<?php echo $product->get_categories(); ?>

Much appreciated :)

Here is the full code

<ul class="row-fluid">

        <?php
            $args = array ( 'post_type' => 'product', 'stock' => 1, 'posts_per_page' => 4, 'product_cat' => 'news', 'orderby' => 'date','order' => 'DESC' );
            $loop = new WP_Query( $args );
            while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>

                    <li class="span">    

                        <a id="id-<?php the_id(); ?>" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">

                            <?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="Placeholder" width="65px" height="115px" />'; ?>

                            <h3><?php the_title(); ?></h3>
                            <?php echo $product->get_categories(); ?>

                               <p class="price"><?php echo $product->get_price_html();?></p>
<a class="button add_to_cart_button product_type_simple"href="<?php the_permalink(); ?>">More...</a>        
                        </a>
<div class="wer"><?php the_excerpt(); ?></div>
                       <span class="Cart"><?php woocommerce_template_loop_add_to_cart( $loop->post, $product ); ?></span>
                    </li>
        <?php endwhile; ?>
        <?php wp_reset_query(); ?>

    </ul>
Nec
  • 178
  • 2
  • 16
  • possible duplicate of [Get categories from Wordpress Woocommerce](http://stackoverflow.com/questions/21009516/get-categories-from-wordpress-woocommerce) – zod Apr 16 '15 at 21:18
  • not really, the link you posted is a get all categories, i just need the sub ones, thanks thou – Nec Apr 16 '15 at 21:20
  • read through the answers – zod Apr 16 '15 at 21:20
  • i tryed it already, "catchable fatal error: .... " – Nec Apr 16 '15 at 21:23

0 Answers0