WordPress.org

Forums

WooCommerce - excelling eCommerce
[resolved] Woocommerce Nested Category Layout for Products (7 posts)

  1. mrgogo
    Member
    Posted 2 years ago #

    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/

  2. mrgogo
    Member
    Posted 2 years ago #

    I found a sample plug-in toll

  3. mrgogo
    Member
    Posted 2 years ago #

    How to Display WooCommerce Products by Subcategory?

  4. mrgogo
    Member
    Posted 2 years ago #

    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 ?

  5. mrgogo
    Member
    Posted 2 years ago #

    <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 :(

  6. mrgogo
    Member
    Posted 2 years ago #

    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

  7. jmschlmrs
    Member
    Posted 2 years ago #

    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/

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic