• How can I only display the parent product on the category page?

    For example (picture) on my “wicker Dining Sets” category page I have the “catalina Wicker (collection)” showing on there. I just want the parent (main furniture collection) of these to show, not all the individual furniture pieces that are saved under the box checked category.

    Let me know if I need to clarify, thanks

    • This topic was modified 7 years, 9 months ago by taymag.
    • This topic was modified 7 years, 9 months ago by taymag.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter taymag

    (@taymag)

    Any idea?

    Hi, I have the same problem and I solved it this way :
    Open file : /wp-content/plugins/woocommerce/includes/walkers/class-product-cat-list-walker.php
    and find function public function start_el( &$output, $cat, $depth = 0, $args = array(), $current_object_id = 0 )
    and change all code in function to :

    if ( $args[‘has_children’] || $args[‘hierarchical’] ) {

    $output .= ‘<li class=”cat-item cat-item-‘ . $cat->term_id;

    $output .= ‘ cat-parent’;

    if ( $args[‘current_category’] == $cat->term_id ) {
    $output .= ‘ current-cat’;
    }

    if ( $args[‘current_category_ancestors’] && $args[‘current_category’]
    && in_array( $cat->term_id, $args[‘current_category_ancestors’] ) ) {
    $output .= ‘ current-cat-parent’;
    }

    $output .= ‘”>term_id, $this->tree_type ) . ‘”>’ . _x( $cat->name, ‘product category name’, ‘woocommerce’ ) . ‘‘;

    if ( $args[‘show_count’] ) {
    $output .= ‘ <span class=”count”>(‘ . $cat->count . ‘)</span>’;
    }
    }

    have fun.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Only Parent category to display on category page’ is closed to new replies.