This plugin hasn’t been tested with the latest 3 major releases of WordPress. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

Better Section Navigation Widget

Description

Adds a new widget type you can deploy in your sidebar regions (and/or elsewhere) to display section-based navigation, along with the ability to exclude certain pages from showing up.

The title of the widget is the top level page within the current section. The widget then can show all of the page’s published 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. It can also be called by a function inside template files.

It includes a simple widget configuration panel. From this panel you can:

  1. Determine whether the 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. Use a specific widget title (i.e. In This Section), or just use the top level page title
  7. Determine whether the section title should be linked
  8. Determine page sort order (defaults to menu order)

The widget uses standard WordPress navigation classes, in addition to a unique class around the widget, for easy styling. The UL of the page list also has a custom class, bsn-list, that can be altered via the bsn_list_class filter.

Beginning with version 1.5, Better Section Navigation also incorporates the features of the defunct Exclude Pages plugin, giving you the ability to selectively exclude specific pages from appearing in the widget generated by Better Section Navigation. This per-page control is managed via a metabox on the post edit screen. Note: On activation, BSN will automatically import the list of “excluded pages” set via that plugin, so you don’t have to manually re-assign excludes pages before deactivating the old one.

Compatible with WordPress Multisite.

This plugin started life as Simple Section Navigation Widget, but since that plugin hasn’t been updated in a while, we’ve taken up the reins with the goal of keeping it up to date with the latest WordPress conventions (i.e. getting rid of deprecation warnings) and adding a few nice-to-have features while retaining some of the simplicity of the original plugin.

Simple Section Navigation Widget is incompatible with PHP 8.x, so as of October 2022, Better Section Navigation is now a drop-in replacement for Simple Section Navigation Widget. If you’ve been using Simple Section Navigation, you can now use this one instead without changing any settings! NOTE: Deactivate Simple Section Navigation Widget before activating Better Section Navigation.

Screenshots

  • Screenshot of widget output on "Open Source" page under top level page "My Portfolio", running Twenty-Ten theme
  • Screenshot of widget configuration.

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. Widget users can add it to the sidebar by going to the “Widgets” menu under “Appearance” and adding the “Better Section Navigation” widget. Open the widget to configure.
  4. Template authors can call the navigation by using the better_section_nav function. The function accepts a single argument in the form of a classic WordPress set of parameters.
  5. Users who want to display section navigation without adding a widget or editing a template can use the [better-section-nav] shortcode.

FAQ

Can I embed this via a Gutenberg block instead of a widget?

At this time there is no Block nor any plan to create one. Instead, use the shortcode block to embed within a block editor page.

Can I embed this via a shortcode instead of a widget?

Yes, you may use the [better-section-nav] shortcode. This example will will wrap the widget in LI tags, exclude page ID 2, and will output on home page:

[better-section-nav before_widget="<li>" after_widget="</li>" exclude="2" show_on_home="1"]

Can I hard-code this into a PHP template instead of a widget?

Yes, you may call the better_section_nav function, which accepts a single argument in the form of a classic WordPress parameter set like so:

<?php better_section_nav('before_widget=<li>&after_widget=</li>&exclude=2&show_on_home=1'); ?>

What parameters are available for shortcodes/function calls?

Here’s the complete list:

  • show_all – Always show all pages in current section (default: false)
  • exclude – Page IDs, seperated by commas, of pages to exclude (default: ”)
  • hide_on_excluded – No navigation on excluded pages (default: true)
  • show_on_home – Show top level page list on home page (default: false)
  • show_empty – Output even if empty section (default: false)
  • sort_by – Page sort order; can use any WordPress page list sort value
    (default: menu_order)
  • title – Provide a specific widget title; default is the top level page title
    (default: ”)
  • a_heading – Show all pages in section (default: false)
  • before_widget – HTML before widget (default: <div>)
  • after_widget – HTML after widget (default: </div>)
  • before_title – HTML before widget (default: <h2 class="widgettitle">)
  • after_title – HTML after widget (default: </h2>)

Reviews

January 19, 2024
Works perfectly, thanks for taking over the previous project guys, it's a useful plugin.
April 9, 2018
I was pleasantly surprised to see how neat and clean the menu looks and how easy it was to order & nest the pages. Just edit the page, and to the right of the editor you'll see a section called Page Attributes. If you want to nest the page under another page, enter the name of the parent page there. To nest the page two deep, just list an existing child page as its parent. If you have several pages nested together under a single parent page, give each a number in Page Attributes to order them on the front end. There's also a few controls you can play with when you expand the widget. So if you wanted to eliminate the index on your "About Me" page, you could easily do so. I'm likin' it.
March 5, 2018
I've used Simple Section Navigation for years (10?) as a foundation for CMS websites. Will be replacing with BSN; tickled to be able to switch to a supported, regularly updated version, although, except for an update a couple years ago to make it compatible with a PHP update, I've never had any issues with SSN. Willing to bet BSN will be rock-solid as well.
January 19, 2018
I needed a plugin with similar functionality for my recent project and found this up-to-date version. Works great, thanks!
Read all 4 reviews

Contributors & Developers

“Better Section Navigation Widget” is open source software. The following people have contributed to this plugin.

Contributors

Changelog

1.6

  • Add full backward compatibility for Simple Section Navigation. Better Section Navigation is now a drop-in replacement.

1.5.5

  • Eliminating warning-level error regarding undefined nonces in the admin.

1.5.4

  • Correcting bad link in admin; bumping tested-up-to WP version.

1.5.3

  • Fix a bug that prevented the [better-section-nav] shortcode from displaying.

1.5.2

  • Fix a potential fatal error caused by calling the wp_kses() function with an incorrect number of arguments.

1.5.1

  • Attempt to fix fatal error where is_plugin_active() is called before it’s defined.

1.5

  • Introduced a CSS class specific to the UL in the widget, filterable with bsn_list_class
  • Rolled the functionality of the dormant Exclude Pages plugin so individual pages can be suppressed from appearing in widgets.

1.0.2

  • Fixed a bug that caused a fatal “Can’t use function return value in write context” error under PHP < 5.5.

1.0.1

  • Fixed a bug that caused the “Show all pages in section” checkbox in the
    widget settings to do the opposite of what it was supposed to do.

1.0

  • Forked from Simple Section Navigation Widget.
    See that plugin’s changelog for earlier changes.
  • Cleaned up deprecated function calls.
  • Added a shortcode to allow users to display the section nav widget without
    editing any template files.