Simple Section Navigation is a WordPress plugin that adds a widget to your sidebar for section based navigation. Easy to configure and essential for CMS implementations!

New version 1.3 added June 28, 2009!

Download version 1.3 from the WordPress plugin repository »

Description

The title of the widget is the top level page within the current section. Shows all page siblings (except on the top level page), all parents and grandparents (and higher), the siblings of all parents and grandparents (up to top level page), and any immediate children of the current page. Can also be called by a function inside template files.

It includes an easy to use configuration panel inside the WordPress settings menu. From this panel you can:

  1. Determine whether the section navigation widget should appear on the home page
  2. Override standard behavior and have the widget show all pages in the current section
  3. Determine whether the widget should appear even if the section only has one page (the top level)
  4. Provide a list of pages to exclude from the output
  5. Determine whether the section navigation should still appear when viewing excluded pages
  6. Determine whether the section title should be linked

The widget uses standard WordPress navigation classes, in addition to a unique class around the widget, for easy styling.

Compatible with WordPress MU.

Considerable under the hood changes in 1.2 fixes page flattening / depth issue by “excluding” instead of
“including” pages.

Installation

  1. Install easily with the WordPress plugin control panel or manually download the plugin and upload the extracted folder to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Configure the plugin by going to the “Section Nav” menu item under “Settings”
  4. Widget users can add it to the sidebar by going to the “Widgets” menu under “Appearance” and adding the “Simple Section Nav” widget
  5. Template authors can follow the instructions in the “Section Nav” menu to easily add it to a widget-less template.
  6. Determine whether the section title should be linked.
  7. Determine page sort order (defaults to menu order)

Screenshots

Sceenshot of output, using widget. Get Informed is a top level pages, and Clinics is a sub page.

Simple Section Navigation Configuration Screenshot

Other Notes

v1.1 changes

  • Added ability to link heading, which also wraps it in a unique id
  • Improved excluded pages handling
  • Ability to exclude entire sections from using the widget

v1.1.2 changes

  • Fixed occasional “flattening” of navigation (no hierarchy) and out of order pages issues

v1.2 changes

  • DEFINITIVE FIX FOR PAGE FLATTENING / FLAT HIERARCHY / NO DEPTH ISSUES
  • Performance improvements

v1.3 changes

  • Ability to set page sort order (still defaults to menu order)
  • Applies current_page_item and current_page_ancestor classes to optional heading link
  • Easy access to settings panel from plug-ins page
  • WordPress 2.8 compatibility check

Possible future features based on demand:

  • Ability to include an “Overview” link that links to top level page within section
  • Override settings panel configuration using function in template (allowing multiple instances with different configurations)
  • Ability to treat blog categories as sub pages of blog home
  • Light weight mode for sites with only 2 levels of pages

If you’re interested in the origins of this plugin and how it works under the hood, check out this blog post.

As always, feedback and suggestions are welcome!

42 Responses to “Simple Section Navigation (WordPress Plugin)”

  1. April says:

    Brilliant, thank you!!!! This has solved my problem with more than one type of custom wordpress navigation. A total blessing for me, who couldn’t entirely follow your article about get_post_ancestors but desperately needs page “sections”. Donation on the way!

  2. Karl says:

    Thanks for this, great that you’ve attempted to solve this and package it up as a widget! Good work.

    I’ve got a bit of an odd output though and I’m not sure if it’s meant to work this way or not, but I looks odd to me. If I output the widget and only show the sibling and children and I’m three levels down, I get this:

    A1a
    A1b
    A1
    A2
    A
    B
    C
    D

    So each level down gets output on top of the last one, and it’s all in a plain list of:

    ul
    li
    li
    li
    /ul

    with nothing to differentiate the levels. On the other hand, if I chose the option in the admin to “Show all pages in section”, I get a proper list:

    A
    -A1
    –A1a
    –A1b

    and so on. The problem then is that it outputs all the menus and I only want to output the grandparents, parents, siblings and children of current menu. But then I’m running into the problem above..

    Any info on this would be greatly appreciated!

  3. Jake Goldman says:

    Karl – I’m not entirely sure I follow. You’re saying if you’re three levels down (i.e. Top Level Page, Sub Page, Sub-Page of Sub-Page), that the navigation “flattens” instead of being in a hierarchy?

    That’s definitely not the expected output, and not what it’s doing in my test environments!

    Is there a link where I could see this in action? I may need to see “under the hood” of your own setup. The first that springs to mind is that there may be a conflicting plug-in… ?

  4. jardo says:

    thank you _so much_ for this, this is almost exactly what i wanted :) .

    let’s see if i can explain this properly.

    when we’re on a top level page with children, the plugin lists all children, obviously.

    now if we’re on a child page, the plugin lists all children of the parent page, including the child page we’re on _linking_ it basically to itself. i don’t think it’s good.

    i wish there was an option to configure the plugin to exclude this behavior.

    would this be possible? do you find it would be an important addition to the current functionality?

    again, thanks so much, you really made my day.

  5. April says:

    This may be obvious, but how do I keep the ’section’ nav item highlighted when on children and grandchildren pages?

  6. Jake Goldman says:

    April – Can you clarify the question? Are you asking how you differentiate a page that’s within the current hierarchy? So if you’re on a third level page, the second level page (its parent) should stand out?

    Assuming you’re looking for something along those lines, the answer is to use CSS. If you look at the HTML you’ll notice that the LI tags have a variety of classes (i.e. “current_page_ancestor”) that your stylesheet can reference to provide some emphasis or other differentiated styling.

  7. April says:

    Hmm, that’s the problem – for some reason my top level nav does not have the class “current_page_ancestor” applied to it when on it’s child/grandchild pages. For instance, on this page here on your site I see that “Software” does have that class, but on my site it does not even on the equivalent sub-sub-page. I’m not sure I setup the plugin call right even though it works like a charm in all other ways.

    I have set up my nav like so:

    Where the “toplevelnav” are the 4 sections, and supposed to be ancestors, and “nav” includes all of the pages and subpages underneath it.

    Do you see any obvious reasons that the ancestor class wouldn’t be applying to the “toplevelnav”?

  8. April says:

    oops, let me try that code again..

  9. April says:

    hmm.. code tags?

  10. April says:

    Never mind my highlighting question afterall! I ended up styling the top level ‘Section’ nav using conditional tags instead.

  11. Jake Goldman says:

    April – sorry for the delayed response!

    I’m still curious about the problem. You did call the plug-in correctly.

    It sounds like there’s not an issue with the “section nav”, but your top level nav retaining proper styles? I assume you’re using the generic wp_list_pages to generate that? Is there a URL I can look at?

  12. April says:

    Right, the top level nav doesn’t seem to be retaining the “current_page_ancestor” styles. The conditional tags aren’t the best option so I appreciate any insight you have on how to make the styles work.

    Here’s the URL: http://www.treelightdesign.com/stage/features/

    Yes, the top level nav (Features / Customers / Benefits / Pricing) is using a simple wp_list_pages tag.

    Then everything in the dropdown menus is called by the simple_section_nav tag.

    And to keep things simple, I made the following styles:

    .current_page_item: orange border
    .current_page_parent: red border
    .current_page_ancestor: green border

    So when I’m on a grandchild page of “Features”, (http://www.treelightdesign.com/stage/features/modules/invoicing/) then shouldn’t “Features” be green?

    Thanks for your assistance!

  13. NicoMollet says:

    Hey, great plugin you have here.

    I wonder what the feature “Ability to treat blog categories as sub pages of blog home”. Is it like the feature “Categories menu” from the plugin WPML.org ?

  14. Karl says:

    ,

    Sorry for the delayed response, I was working on other parts of the site.

    Yep, could be a conflicting plugin, the behaviour is a bit strange. It does flatten three levels down for me like you describe, but in reverse order (sub-sub pages on top).. confusing indeed! Wish I could send a link, but it’s on a test-server.

    Haven’t had a chance to deactivate all plugins or trial it further, for this project I went with the Fold Page List plugin in the end, with a snippet to split out just the 2nd level down http://www.brustpumpe.de/fold-page-list-geteilte-navigation/

    Might have a look at your plugin again for another project, good luck with it!

  15. Jake Goldman says:

    NicoMollet – that feature (which I hope to roll out in the next update) allows you to treat blog categories as though they’re sub pages of the blog page. So, for example, if you create a top level page called “Blog”, and make that your blog page in the settings, when you visit that top level page, the Simple Section Navigation would output permalinks to the top level blog categories as sub pages of “blog”.

    Hope this makes sense!

  16. Fred says:

    Karl and I are having the same issue. Though, I have no other plugins installed.

  17. Jake Goldman says:

    The loss of hierarchy issue seems to be resolved… download the latest build (1.1.2) for the fix!

  18. Fred says:

    Many thanks. Super nice plugin, guys!

  19. Svein Are says:

    I’m looking for a navigation plugin that does the following:
    - Shows only root pages (when current page is home)
    - Shows root pages + sub-pages of the current page

    To me it seems like this plugin only shows the siblings/children of current page. Not the whole hierarchy.

    I want this view:

    (Current page: Home):
    - Section A
    - Section B
    - Section C
    - Section D

    (Current page: Section B, therefore I can see the sub-pages):
    - Section A
    - Section B
    – Subsection B1
    – Subsection B2
    - Section C
    - Section D

    Is this supported?

  20. Jake Goldman says:

    Svein – that’s close to what this plug-in does, but not exactly.

    The plug-in can be set to show top level pages (”sections”) on the home page, but once inside of each section it uses that top level page (i.e. “Section B”) as the heading for the navigation, with its children listed beneath. Using your example:

    (Current page: Home):
    Heading: Home
    - Section A
    - Section B
    - Section C
    - Section D

    (Current page: Section B, therefore I can see the sub-pages):
    Heading: Section B
    - Subsection B1
    - Subsection B2

    (Current page: Subsection B1):
    Heading: Section B
    - Subsection B1
    –B1-1
    –B1-2
    - Subsection B2

    The intent was not really to create a site-wide “smart” navigation; the typical use case is a site with a persistent list of top level pages in the heading, that wants a sidebar with navigation within that section, once inside one of those top level pages.

    The functionality you’re seeking is most easily accomplished with CSS. Just use descending LI classes combined with various “current” classes to control display of sub pages.

    If you don’t want to use the CSS approach, and would like to sponsor a small modification to this plug-in to support your use case, let me know and I’ll email you with the details.

  21. Roger says:

    Hi Jake,

    I have one quick question.

    How can I show the children of the sub page under its parent rather than on the top.

    It ruins the need of it as it start showing the sub pages on the top, where as it should show them under the specific child to which they are parent of.

    Please help.

    any help regarding CSS or Code would be appreciated.

  22. Jake Goldman says:

    Roger – they are supposed to show up as children of the parent page. It appears my “fix” in 1.1.2 actually breaks some previously working instances. It appears to be rooted in a WordPress bug related to the “include” option. I am going to put out another update very soon.

  23. Roger says:

    Hi Jake,
    Thank you very much for your reply.

    My question was actually exactly as Svein Are’s. The code is perfect and generated children perfectly but why does it show it at the top?

    I actually, and I am sure many other would like to show the third level children under the 2nd level parent. Just like Svein Are wanted.

    I will be very thankful if you can give a fix for that within PHP. That would be really helpful.

  24. Roger says:

    Any help Jake :-(

  25. Jake Goldman says:

    Roger – I have emailed you with a beta version that may fix your problem. I’m trying to work around an apparent bug with WordPress page lists and the “include” option.

  26. Thank you for this plugin – this is exactly what I was looking for! Would love to have an admin option to turn the section title off, but that can be done easily enough in the CSS.

    Also, you probably have this documented somewhere that I missed, but the user needs to explicitly assign page order numbers to each page – for whatever reason if the value is left at the default of “0″, the subpages were jumping to the top of the nav list instead of staying under the parent.

  27. Jake Goldman says:

    Edwards – thanks for the feedback.

    I’m aware of the page order bug… it’s tied to the other issues with “flattening” navigation folks have mentioned in the comment. I’m looking at reworking the plug-in a bit to work around what I believe to be a WordPress bug with “include” page listings.

  28. Roger says:

    Hi Jake,

    I am sorry but I didn’t receive it. Must be some problem. Can you email here instead:- ayishaakram[at]gmail.com

    I will be very thankful.

    Regards.

  29. Loren says:

    Thank you for a valuable plugin. I had tested it some months back and ran into the “flattening” issue. So I had been using the Sub Pages widget (http://wordpress.org/extend/plugins/subpages-widget/) but it does not seem to be supported any longer.
    This plugin works very nicely in conjunction with the Page Template Extended plugin (http://wordpress.org/extend/plugins/page-template-extended/ which I am not sure is supported either) allowing for great CMS-like capability. Page id based templates then form the “sections” for the site. Great work!

  30. Jake Goldman says:

    Loren – glad to hear that the plug-in has been useful!

    All – a fix is coming “soon” for the page flattening issue. Unfortunately, I was out for about 10 days, and I’m in catch up mode. In the interim, as someone else indicated, if you explicitly define a page order using a third party plug-in like pageMash or using the page order drop down, the flattening should not occur.

  31. Loren says:

    Is there a way of adding the WordPress current_page_item class to the title of the widget?

  32. Jake Goldman says:

    Loren – we can add that to the next revision.

  33. Loren says:

    Jake – That is great! I am still developing the site that I am using this on but it really seems to be exactly what this type of website needed. Thanks again.

  34. [...] actually released a plug-in that makes “section” or “top level page” WordPress navigation a cinch. But there are plenty of reasons outside of navigation that may require you to indentify [...]

  35. Mike says:

    Excellent plugin! Simple and elegant. As a feature request, I suggest a sort order option to the settings, so the menu can be displayed alphabetical, by date, page order, page ID, etc. The default is page order, which doesn’t work when you want a large number of pages to be sorted automatically.

  36. Jake Goldman says:

    Great suggestion, Mike.

    We’ll incorporate that, as well as Loren’s suggestion, in the next update.

  37. Jeff says:

    How do I wrap it in a div so I can stylize just this list? Would it be easier to just call to it from my template? If, so how do I do that? I tried using the call function, but I have no idea how to do that properly. Any help would be wonderful. Thanks!

  38. Susan says:

    This plugin is terrific, but I’m having one problem — page/child/grandchild nav are showing up correct, formatting is correct via my CSS, BUT I’m getting an extra blank line at the end of my indented grandchild link list before the child page list continues — i.e (don’t know if my formatting below will show up tho):

    PARENT
    – Child
    – Grandchild

    – Next Child

    I am completely stumped as to what I need to do in my CSS to fix this. It appears that something is causing that extra line at the end of a child group, because when I switch the setting to display all pages in section, the end break happens in between all Child/Grandchild groups.

  39. Jake Goldman says:

    Jeff – if you’re using widgets, WordPress automatically wraps the widget in an element (an “li” in the default theme) with a special class name that corresponds to the widget name. In the case of this plugin, the widget’s wrapper gets a “widget_pages” class. You can use that reference to uniquely style this widget.

    To output it in a template file, you need to execute the “simple_section_nav();” function in a PHP code block (as explained in the documentation and on the configuration page). You can put whatever you like around, including a “div” tag with a unique ID.

    If you need further assistance, please use the “request a quote” button at the top of the page!

  40. Jake Goldman says:

    Susan: it sounds like you have a “margin-bottom” or “padding-bottom” property attached to unordered lists (UL’s). Do you have a link where we can see this in action?

    If this is not a bug with the extension, but simply a matter of CSS expertise, I’d politely ask that you strongly consider a small donation in exchange for our time assisting you.

  41. Susan says:

    Thanks — no margin-bottom or padding-bottom properties at all on this list — I was just wondering if there was something in the plugin that automatically added that extra line. I’m now sure it’s my CSS, because when I try the list without it, all is OK. I’ll keep plugging away.

    And I do plan on donating as soon as I get everything working — thanks a bunch.

  42. Jake Goldman says:

    Susan – good luck with the CSS! The forthcoming donation is very appreciated… it’s hard for us to walk the line between extension support and supporting people’s sites!