OnPoint Plugins

  • Plugins
    • Advanced Sidebar Menu
    • Go Live Update Urls
  • About
    • Services
    • Showcase
  • Blog
  • Contact
  • Support
  • Log In
← Back to support

Close Open Category When New One Selected

Resolved

Requested: 1 year and 11 months ago

Hi Matt,

Hope all is well with you.

I am trying to get Categories Pro to only show one category at a time, as in when you open a category, any previous category is closed. I tried:

add_action( ‘wp_print_footer_scripts’, function () {
?>
<script>
( function( $ ) {
setTimeout( function() {
$( ‘.child-sidebar-menu > .has_children’ ).click( ‘> span’, function() {
var parent = $( this );
$( ‘.child-sidebar-menu > .has_children.open’ ).each( function() {
if ( parent.text() !== $( this ).text() ) {
asm_pro.accordion._expand_sub_menu( $( this ), $( this ).find( ‘> span’ ) );
}
} );
} );
}, 1000 );
} )( jQuery );
</script>
<?php
} );

in the functions file but it did not seem to work. This was code you gave to someone a while back so thought I would try it. Perhaps there is already functionality for this in the later versions but I could not find it.

Dave

 

Plugin: Advanced Sidebar Menu

  1. OnPoint Plugins

    1 year and 11 months ago

    Hi Dave,

    The JavaScript required to make this work will depend on which level of menu items you are trying to close when another is opened.

    For instance, you are showing the top level items and would like that level close an open item when another is opened, you may add the following custom JavaScript to your site.

    If you would like the first level children to function in this way, the following JavaScript will enable the functionality.

    You may add both if you want both both levels to have the functionality.

    If you have any issues, it will help to have a link to your site so we can see what you’re targeting.

    Have a great night!

     

New Response Cancel reply

You must be logged in to respond. Only PRO members are allowed to respond to support requests.

© 2023 · WordPress Development · Terms Of Service · Privacy Policy · Cookie Policy · Log in

  • Plugins
  • Blog
  • Contact