Creates a new widget for listing section-based navigation. Essential for contextual navigation when using WordPress as a CMS! Also implements a functi …
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:
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.
/wp-content/plugins/
directory.better_section_nav
function. The function accepts a single argument in the form of a classic WordPress set of parameters.[better-section-nav]
shortcode.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.
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"]
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'); ?>
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 valuetitle
– Provide a specific widget title; default is the top level page titlea_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>
)bsn_list_class