OnPoint Plugins

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

Display all top level pages in menu

Resolved

Requested: 4 years and 9 months ago

I just purchased this plugin but run into slight problem. I was using the GD Pages Navigator plugin but it did not have accordian navigation so I purchased yours because I was too lazy to right my own js for the GD plugin. The GD plugin does what I describe below but not in an accordian menu style, just a static full list type menu style.

Your plugin does what I want it to in terms of the accordian navigation but one thing it does not do is display all top level posts when I am using the widget to display on all pages. To be clearer this is what I have;

1. Custom Post Type PositiveFamilies
2. Top Level posts in this custom Post type – lets call them TopA and TopB for ease
3. When I show your widget on other pages I would like TopA and TopB to be shown as an accordian menu with all the sub pages underneath the menu, however I cannot get this to work. No matter what settings I use, I do see the accordian menu, unless I navigate to say the post TopA then it starts to appear. Essentially I wan the accordian menu to always be showing a full accordian menu of the PositiveFamilies posts (ie showing TopA and TopB) no matter if I am on other pages/post types ie the menu should look like below on all pages/posts

TopA
TopB

If I am on a PositiveFamilies post (eg TopA-SubPage1) then the accordian menu should be expanded along the current path eg

TopA
SubPage1
ToB

How can I get this to work the way I need it?

Plugin: Advanced Sidebar Menu

  1. OnPoint Plugins

    4 years and 9 months ago

    The menu requires a parent page to generate the parent/child hierarchy.

    If you assign a shared parent page to both TopA and TopB and uncheck the “Display highest level parent page” option in the widget , the menu will display as requested.

    The page hierarchy would look like this:

    SharedParent
    -> TopA
    -> -> SubPage1
    ->TopB

    Let me know if you have any questions.

     

     

  2. spotart

    4 years and 9 months ago

    Hi Matt,

    I realise I can do that but that will create a URL structure for those custom Posts that I don’t want?

  3. OnPoint Plugins

    4 years and 9 months ago

    There is a way to do this using a template override.

    1. Create a folder in your active theme called ‘advanced-sidebar-menu’
    2. Inside the folder create a new file ‘page_list.php’
    3. Add the following code to that file
    4. Select the “Include highest level parent in accordion” option in the widget
    <?php
    $menu        = Advanced_Sidebar_Menu_Menus_Page::get_current();
    $list_pages  = Advanced_Sidebar_Menu_List_Pages::factory( $menu );
    $child_pages = $list_pages->get_child_pages( $menu->get_top_parent_id(), true );
    $content     = '';
    $widget_args = $menu->get_widget_args();
    
    $menu->title();
    
    $content .= '<style>#' . $widget_args['widget_id'] . ' .parent-sidebar-menu{margin-bottom:0 !important;}</style>';
    
    //Display parent page
    
    $ids         = get_posts( array(
       'post_type'   => $menu->get_post_type(),
       'numberposts' => 100,
       'fields'      => 'ids',
       'orderby'     => $menu->get_order_by(),
       'post_parent' => 0,
    ) );
    $parent_args = $list_pages->get_args( 'parent' );
    $list_args   = $list_pages->get_args( 'display-all' );
    foreach ( $ids as $_page_id ) {
       $content                .= '<ul class="parent-sidebar-menu" >';
       $parent_args['include'] = $_page_id;
       $content                .= wp_list_pages( $parent_args );
    
       $child_pages = $list_pages->get_child_pages( $_page_id, true );
       if ( ! empty( $child_pages ) ) {
          $content               .= '<ul class="child-sidebar-menu">';
          $list_args['child_of'] = $_page_id;
          $content               .= wp_list_pages( $list_args );
          $content               .= '</ul><!-- End .child-sidebar-menu -->';
       }
    
       $content .= '</li></ul><!-- End .parent-sidebar-menu -->';
    }
    
    
    return $content;
    
  4. spotart

    4 years and 9 months ago

    Hi Matt,

    Yep that seems to have worked perfectly.  I can make any extra tweaks from there but I would think that would be a useful option to include in the base code rather than require a plugin override.

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