Hide woocommerce subcategories by default

This topic has 20 replies, 3 voices, and was last updated 9 years, 5 months ago ago by Jack Richardson

  • Avatar: larsjanssen64@gmail.com
    larsjanssen64@gmail.com
    Participant
    July 5, 2016 at 13:46

    Hello,

    I’ve added this to my functions.php in my child theme:

    function exclude_product_cat_children($wp_query) {
    if ( isset ( $wp_query->query_vars['product_cat'] ) && $wp_query->is_main_query()) {
        $wp_query->set('tax_query', array(
                                        array (
                                            'taxonomy' => 'product_cat',
                                            'field' => 'slug',
                                            'terms' => $wp_query->query_vars['product_cat'],
                                            'include_children' => false
                                        )
                                     )
        );
      }
    }
    add_filter('pre_get_posts', 'exclude_product_cat_children');

    So that the subcategories are hidden by default. But it looks like my functions.php in my childtheme is not being red. Because when I var_dump at the top of the page nothing happens? Could there be something wrong?

    Thankyou

    19 Answers
    Avatar: Eva
    Eva Kemp
    Participant
    July 5, 2016 at 14:11

    Hello,

    Do you want to hide subcategories in Shop sidebar?
    Please provide wp-admin and FTP credentials in Private Content.

    Regards,
    Eva Kemp.

    Avatar: larsjanssen64@gmail.com
    larsjanssen64@gmail.com
    Participant
    July 5, 2016 at 14:22

    Thankyou. Please see the private section.

    Please, contact administrator
    for this information.
    Avatar: Eva
    Eva Kemp
    Participant
    July 5, 2016 at 17:03

    Hello,

    Please clarify where you want to hide subcategories.
    Show a direct link where they are shown.

    Regards,
    Eva Kemp.

    Avatar: larsjanssen64@gmail.com
    larsjanssen64@gmail.com
    Participant
    July 5, 2016 at 18:04

    Hello,

    I want to hide them in the shop sidebar. For example:

    (see private section)

    There are:

    ASSEN
    BORSTELS
    BORSTELS TOT 25 MM
    BORSTELS VANAF 25 MM
    CLEANING TOOLS
    PROJECTIELEN

    Visible by default. They should be collapsed.

    Please, contact administrator
    for this information.
    Avatar: Eva
    Eva Kemp
    Participant
    July 5, 2016 at 18:19

    Hello,

    To close a category, edit wp-content/themes/royal/js/etheme.js file. Find and comment out line 1808
    $this.find('>li').first().find('.open-this').html(minusIcon).parent().addClass('opened').find('ul.children').show();

    Regards,
    Eva Kemp.

    Avatar: larsjanssen64@gmail.com
    larsjanssen64@gmail.com
    Participant
    July 5, 2016 at 19:37

    Hello,

    Thankyou. When I comment that out nothing happens. Also when
    I comment the entire file out nothing happens. I tried it in incognito but
    still nothing changes. Should I do something else?

    Thanks again.

    Avatar: Eva
    Eva Kemp
    Participant
    July 6, 2016 at 08:32

    Hello,

    Please provide us with FTP credentials in private content.

    Regards,
    Eva Kemp.

    Avatar: larsjanssen64@gmail.com
    larsjanssen64@gmail.com
    Participant
    July 6, 2016 at 09:48

    Thankyou please see the private section.

    Please, contact administrator
    for this information.
    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    July 6, 2016 at 11:15

    Hello,

    The credentials are incorrect, we are getting an error “Error: Authentication failed.”.
    Please provide correct FTP login details.

    Best regards,
    Jack Richardson.

    Avatar: larsjanssen64@gmail.com
    larsjanssen64@gmail.com
    Participant
    July 6, 2016 at 11:20

    Hello,

    Please use sftp I don’t have ftp information.

    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    July 6, 2016 at 12:11

    Hello,

    I used sftp and got the error “Error: Authentication failed” which means login details are incorrect.
    So please check them.

    Best regards,
    Jack Richardson.

    Avatar: larsjanssen64@gmail.com
    larsjanssen64@gmail.com
    Participant
    July 6, 2016 at 15:05

    I am very sorry. I had the wrong password.
    (please see private content)

    Please, contact administrator
    for this information.
    Avatar: Eva
    Eva Kemp
    Participant
    July 6, 2016 at 16:05

    Hello,

    I’ve edited the file etheme.js and commented the lines 1805-1809.
    Please check the page now.

    Regards,
    Eva Kemp.

    Avatar: larsjanssen64@gmail.com
    larsjanssen64@gmail.com
    Participant
    July 6, 2016 at 17:58

    Hello Eva,

    The subcategories are still visible by default.
    (see private section)

    Please, contact administrator
    for this information.
    Avatar: Eva
    Eva Kemp
    Participant
    July 6, 2016 at 18:43

    Hello,

    As I see subcategories are closed http://prntscr.com/bplnrg.

    Clear browser cache and check again.

    Regards,
    Eva Kemp.

    Avatar: larsjanssen64@gmail.com
    larsjanssen64@gmail.com
    Participant
    July 7, 2016 at 09:02

    Hello,

    Yes I can see it now! Thankyou! Never had so good
    support with a theme that I bought.

    Can I put this file in my child-theme or should I replace it with
    every update?

    Thankyou!

    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    July 7, 2016 at 10:18

    Hello,

    You can move changed .js file in your child theme following these steps:
    1. Add the code in your child theme functions.php:

    add_action( 'wp_enqueue_scripts', 'etheme' );
    function etheme() {
        wp_enqueue_script( 'etheme', get_stylesheet_directory_uri() . '/js/etheme.js' );
    }

    2. Copy edited etheme.js file into the “wp-content/themes/royal-child/js” folder.

    And if you are satisfied with our support be so kind to leave a comment on Theme Forest site https://themeforest.net/item/royal-multipurpose-wordpress-theme/8611976/comments .
    Thank you.

    Best regards,
    Jack Richardson.

    Avatar: larsjanssen64@gmail.com
    larsjanssen64@gmail.com
    Participant
    July 7, 2016 at 16:07
    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    July 7, 2016 at 16:52

    Hello,

    Thank you, we appreciate it very much.

    Best regards,
    Jack Richardson.

  • Viewing 20 results - 1 through 20 (of 20 total)

The issue related to '‘Hide woocommerce subcategories by default’' has been successfully resolved, and the topic is now closed for further responses

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.