• Resolved cactus07

    (@cactus07)


    Hi everyone.
    I am using categories and attributes form my products.

    I obtain a list of my attributes like this.

    echo '<ul>';
        $terms = get_terms( 'pa_country' );
        foreach($terms as $item_term ): ?>
          <li class="data_tag">
          <?php $term_link = get_term_link( $item_term ) ?>
    
             <a href="<?php echo  $term_link; ?>" class="name_category"> <?php echo $item_term->name; ?> </a>
              <img src="<?php echo get_template_directory_uri(); ?>/img/<?php echo $item_term->name; ?>.jpg" class="img-responsive"/>
          </li>
        <?php endforeach;
        echo '</ul>';

    when I click in the links this show me all the product with the same attribute, but How to do , if I want the product by category and attribute…

    For example, I have three products all with attribute “dark” but two of this are from category “day” and the other one is category “night”

    Now when I click in the link this show me three, but I want to show the categories like Day (2product) and Night (1 product) How to do that?

    Any idea, thanks in advances!

    https://ww.wp.xz.cn/plugins/woocommerce/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Mike Jolley

    (@mikejolley)

    I think you’ll need to generate a custom link for this – using layered navigation, linking to the category, and hardcoding in the values for the attributes for layered nav to pick up.

    If you go there manually you can see the URL structure needed.

    Thread Starter cactus07

    (@cactus07)

    Hi Mike Thanks, I try that you say-…

    I create this custom link

    http://localhost/....../shop/?product_cat=9&filter_country=20

    But return error 404, don’t find the page.

    Any idea??

    Thread Starter cactus07

    (@cactus07)

    Solved!!!

    I have to pass the name of the category no the ID. So

    http://localhost/....../shop/?product_cat=nombreCategory&filter_country=20

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘product by category’ is closed to new replies.