• Hi,
    once again: very good theme and a brease to work with.

    I noticed that your (tab) menu script only displays the main categories (uptill 5, but if needed more: can be added in products/categories and by modifying the code in the section.tabmenu.php :-).

    But in my case there are also subcategories ( snacks as main, sandwiches/burgers/kebab/… as subcategories).
    Is there a way that when the main category has subcategories, they are shown underneath the main category (also as a button list) , and when clicked they show their products (dishes)? If so, please guide how to do this.
    Ps:
    (woocommerce itself is being configured like this).

    Thanks for your feedback.
    Have a nice day!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter lobodesign

    (@lobodesign)

    Update:
    i managed to get the titles of the subcategories under the main categories when the main category is clicked, which is allready a step forward.

    However when subcategory is clicked, it still shows all the products of the main category instead of only the products in the subcategory.

    To give an example:
    Before and by default:
    only main category possible :snack
    when clicked i receive a list of all sandwiches and hamburgers.
    What I want to achieve:
    Main category: snacks
    Subcategories: sandwiches / hamburgers
    When you click on snacks, first you get buttons “sandwiches” and “hamburgers” (done ).
    If you click on “sandwiches” you get the different sandwich products ( not done ??
    If you clik on “hamburgers” you get the different hamburger products.( not done ??
    I receive under each subcategory still the list of all sandwiches and hamburgers.

    I presume it has to do with the WPquery in section.tabmenu.php.
    But i cannot figure out the correct one for displaying products of subcategories.
    Perhaps you guys can give a tip?

    Thanks in advance.

    Hello @lobodesign,

    I was in talk/discussion with the development team.

    I have discussed them regarding your requirement and they have provided me with the below code. Hope this will help you.

    $parent_id = $product_category->term_id;
        $termchildren = get_terms('product_cat',array('child_of' => $parent_id));
        foreach($termchildren as $termchild){
            $child_cat_id = $termchild->term_id;
            $argument = array(
                'post_type' => 'product',
                'tax_query' => array(
                    array(
                        'taxonomy'  => 'product_cat',
                        'field'     => 'term_id',
                        'terms'     => $child_cat_id,
                    )
                )
            );
            $child_post = new WP_Query( $argument );
        }

    Please let us know for any further queries.

    Thank you.

    Thread Starter lobodesign

    (@lobodesign)

    Hi there,
    thank you for supplying the code,much appreciated.

    I will incorporate it in your (adapted) section.tabmenu.php and let you know if it works :-).

    Speak soon!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Subcategories in tab menu’ is closed to new replies.