Support » Plugin: WooCommerce » Woocommerce Nested Category Layout for Products

  • Resolved mrgogo

    (@mrgogo)


    Hi, I tried to do but did not. my sample page http://kafe14.izmok.com/online-siparis/

    Problem: How do I make products under the categories. All products are currently under categories seems. but I just want to appear in the products belong to the category

    content-product_cat.php

    <h3>
    <?php echo $category->name; ?>
    <?php if ( $category->count > 0 ) : ?>
    
    <?php while ( have_posts() ) : the_post(); ?>
    
    <?php woocommerce_get_template_part( 'content', 'product' ); ?>
    
    <?php endwhile; // end of the loop. ?>
    <?php endif; ?>
    </h3>

    Pls Help… 🙂

    http://wordpress.org/extend/plugins/woocommerce/

Viewing 6 replies - 1 through 6 (of 6 total)
  • I found a sample plug-in toll

    How to Display WooCommerce Products by Subcategory?

    There is a problem but recent work

    <h3>
    <?php echo $category->name; ?>
    <?php if ( $category->count > 0 ) : ?>
    
    <?php
    $args = array(
    'post_type' => 'product',
    'posts_per_page' => 12,
    'product_cat' => testcategoryname,
    'orderby' => 'name',
    'order' => 'ASC',
    );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
    <?php woocommerce_get_template_part( 'content', 'product' ); ?>
    <?php endwhile; ?>
    <?php endif; ?>
    </h3>

    The problem stems from category name
    something similar to the following code required

    <h3>
    <?php echo $category->name; ?>
    <?php if ( $category->count > 0 ) : ?>
    
    <?php
    $args = array(
    'post_type' => 'product',
    'posts_per_page' => 12,
    'product_cat' => $category->name,
    'orderby' => 'name',
    'order' => 'ASC',
    );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
    <?php woocommerce_get_template_part( 'content', 'product' ); ?>
    <?php endwhile; ?>
    <?php endif; ?>
    </h3>

    'product_cat' => $category->name, Not work 🙁 How to do ?

    <h3>
    <?php echo $category->name; ?>
    <?php if ( $category->count > 0 ) : ?>
    
    <?php
    $testvalue = $category->name;
    $args = array(
    'post_type' => 'product',
    'posts_per_page' => 12,
    'product_cat' => $testvalue,
    'orderby' => 'name',
    'order' => 'ASC',
    );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
    <?php woocommerce_get_template_part( 'content', 'product' ); ?>
    <?php endwhile; ?>
    <?php endif; ?>
    </h3>

    Not Working 🙁

    Ok ok Work :D:D:

    <h3>
    <?php echo $category->name; ?>
    <?php if ( $category->count > 0 ) : ?>
    
    <?php
    $value2 = $category->slug;
    $args = array(
    'post_type' => 'product',
    'posts_per_page' => 12,
    'product_cat' => $value2,
    'orderby' => 'name',
    'order' => 'ASC',
    );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
    <?php woocommerce_get_template_part( 'content', 'product' ); ?>
    <?php endwhile; ?>
    <?php endif; ?>
    </h3>

    RESOLVED

    Thank you for help do not

    Another solution is to use WooCommerce shortcodes.

    You can insert shortcodes as follows:

    <?php echo do_shortcode( '[fblike]' ); ?>

    So for this application, you can insert:

    [product_category category="foo"]

    into your template file (preferably in your child theme).

    See http://docs.woothemes.com/document/woocommerce-shortcodes/ and http://docs.woothemes.com/document/shortcodes/

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Woocommerce Nested Category Layout for Products’ is closed to new replies.