OnPoint Plugins

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

Custom UL classes and disable menu box in pages/posts

Resolved

Requested: 3 years and 1 month ago

We just bought the Advances Sidebar Pro. So far all good, but I have two questions:
– How can we add own classes to the <ul> element of a menu? Filter?
– How can we disable the Advances Sidebar Menu Box in pages/posts?

Thanks

Plugin: Advanced Sidebar Menu

  1. OnPoint Plugins

    3 years and 1 month ago

    You may accomplish this with a template override.

    Create a folder in your active theme called ‘advanced-sidebar-menu’
    Copy the page_list.php or category_list.php from the plugins ‘views’ folder into the folder you just created.
    Edit the ul elements in these new files.

  2. bombelli

    3 years and 1 month ago

    Thanks for your feedback.
    And what about that?
    How can we disable the Advances Sidebar Menu Box in pages/posts?

  3. OnPoint Plugins

    3 years and 1 month ago

    If you add the following code to your active theme’s functions.php file it will remove the box.

    remove_action( 'do_meta_boxes', array( Advanced_Sidebar_Menu_Pro__Meta__Title::instance(), 'createMetaBox' ) );

  4. bombelli

    3 years and 1 month ago

    Unfortunately this does not help.
    The box is still there
    Thanks

  5. bombelli

    3 years and 1 month ago

    Thanks, I’m talking exactly about this.
    I placed the code in a plugin we load for modifications:

    remove_action(‘do_meta_boxes’, array(
    Advanced_Sidebar_Menu_Pro__Meta__Title::instance(), ‘createMetaBox’
    ));

    But the metabox is still there.

    I have another question regarding Menus for categories.
    I want to show the categories in the blog archive  and single pages, but for some reason they do not appear.

  6. OnPoint Plugins

    3 years and 1 month ago

    If you place the code inside a plugin it must be wrapped in an action otherwise it will run too soon and be unable to de-register the action which is not previously registered. It will work like so.

    add_action( 'do_meta_boxes', function() {
    remove_action( 'do_meta_boxes', array(
    Advanced_Sidebar_Menu_Pro__Meta__Title::instance(),
    'createMetaBox'
    ) );
    }, 0 );

    The plugin requires a category or post to know which categories to display. If you want it to display elsewhere this may be accomplished via a couple of filters.

    add_filter( 'advanced-sidebar-menu/menus/category/is-displayed', '__return_true' );
    add_filter( 'advanced_sidebar_menu_category_ids', 'include_all_parent_terms', 1, 4 );
    function include_all_parent_terms( $term_ids, $args, $instance, $object ) {
    if ( 'category' !== $object->get_taxonomy() ) {
    return $term_ids;
    }

    return get_terms( array(
    'parent' => 0,
    'fields' => 'ids',
    'taxonomy' => 'category',
    'hide_empty' => true,
    ) );
    }

  7. bombelli

    3 years and 1 month ago

    Thanks a lot for your quick feedback!
    Got rid of the metabox 🙂
    Unfortunately, the filter you provided do not help.
    The sidebar menu containing the categories is still not visible.
    Any idea?

  8. OnPoint Plugins

    3 years and 1 month ago

    Are other widget displaying in this sidebar? Like if you add a “Text” widget does it display?

    Another thing worth mentioning, is the categories must have posts assigned to them to show up.

  9. bombelli

    3 years and 1 month ago

    Yes, other widgets appear fine.
    And the taxonomy categories has some categories with associated posts defined.

  10. OnPoint Plugins

    3 years and 1 month ago

    Turns out because your categories are all on the same level you must have the following options checked in the widget to show up:

    Display parent category
    Display menu when there is only the parent category

  11. bombelli

    3 years and 1 month ago

    Thanks a lot.
    Is there a way to define additionally where to show the menu.
    Let’s say on blog and specific archive pages only?

  12. OnPoint Plugins

    3 years and 1 month ago

    There are a number of plugins which allow you to show widgets on particular sections. Here are a couple examples (I am in no way affiliated with these other plugins and can not guarantee their functionality):

    https://wordpress.org/plugins/restrict-widgets/
    https://wordpress.org/plugins/widget-options/

    Otherwise if you would like to do this programmatically, you may update the previously sent filters to:

    add_filter( 'advanced-sidebar-menu/menus/category/is-displayed', '__return_true' );
    add_filter( 'advanced_sidebar_menu_category_ids', 'include_all_parent_terms', 1, 4 );
    function include_all_parent_terms( $term_ids, $args, $instance, $object ) {
    if ( 'category' !== $object->get_taxonomy() ) {
    return $term_ids;
    }

    //ADD CATEGORIES YOU WANT TO DISPLAY TO THIS ARRAY
    $categories = array( 'news' );

    if( is_page( 29 ) || is_category( $categories ) ) {
    return get_terms( array(
    'parent' => 0,
    'fields' => 'ids',
    'taxonomy' => 'category',
    'hide_empty' => true,
    ) );
    }

    return array();
    }

    This will display the widget on your blog page and whatever categories you add to the $categories array, marked with.
    //ADD CATEGORIES YOU WANT TO DISPLAY TO THIS ARRAY

  13. bombelli

    3 years and 1 month ago

    I have another question.
    When I open a single post page from a CPT, then the menu disappears.
    I checked the template and the sidebar is included.
    Any idea?

  14. OnPoint Plugins

    3 years and 1 month ago

    It appears you are using an “Advanced Menu” widget on the page. I am unfamiliar with that widget but I took a quick look anyway. I have confirmed that it is added to that sidebar and the options appear to be correct.

    Due to my lack of knowledge of this widget, I am unable to provide a solution. I recommend reaching out to the developer of the widget to see if they have a solution.

  15. bombelli

    3 years and 1 month ago

    Sorry!
    I confused the widgets!

    But thanks for looking into it!

New Response Cancel reply

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

© 2021 OnPoint Plugins · Terms Of Service · Privacy Policy · Cookie Policy · Log in

  • Plugins
  • Blog
  • Contact