Home Forums Plugin Support WP User Frontend Pro Display Child Category

This topic is: resolved

This topic contains 3 replies, has 3 voices, and was last updated by  Brennen 5 years, 2 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #13261

    tbangun
    Participant
    Post count: 1

    Hello support we want to display all the category as check box input, we have more than 250 categories having child parent relationship, so we need to display child categories only when parent category will be selected, so initially it will be a parent category list as check boxs and if any on the parent is selected we need that corresponding child category will start displaying.

    Thanks

    #13268

    Tareq Hasan
    Keymaster
    Post count: 2831

    Paste this to your themes functions.php and see what happens.

    [php]
    function wpufe_show_hide_checkbox() {
    ?>
    <script type="text/javascript">
    jQuery(function($) {
    var ul = $(‘.wpuf-category-checklist');

    ul.find(‘ul.children').hide();

    ul.on(‘click', ‘input[type=checkbox]', function(e) {
    var check = $(this);
    var child = check.closest(‘li').children(‘ul.children');

    if ( child.lengh !== 0 ) {
    if ( check.is(‘:checked') ) {
    child.show();
    } else {
    child.hide();
    }
    }
    });
    });
    </script>
    <?php
    }

    add_action( ‘wp_footer', ‘wpufe_show_hide_checkbox' );
    [/php]

    #13279

    tbangun
    Participant
    Post count: 1

    Thanks Tareq, Works great ๐Ÿ™‚

    #14080

    Brennen
    Member
    Post count: 2

    Hey Tareq this works great, one question: Can you update it so that if a parent is already checked the children show for that checked category only?

    So basically on page load check if any parent categories are checked and if they are, show the children categories.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Display Child Category’ is closed to new replies.