Sidebars
Sidebars are configured in a Nova theme's right-rail.json, which the
<RightRail /> component uses to render the correct sidebar for pages other
than the homepage.
Unlike non-Nova sites, the homepage does not use sidebars. See the homepage documentation for more details.
Example Configuration
{
"sidebars": [
{
"slug": "single-content",
"label": "Single Content",
"description": "Right rail shown on articles, galleries, lists, and other single pieces of content.",
"conditions": {
"0": "is_single",
"1": "is_singular"
},
"append_sticky_sidebar": true
},
{
"slug": "archive",
"label": "Archive",
"description": "Right rail shown on archives.",
"conditions": [
"is_archive"
],
"append_sticky_sidebar": true
}
],
"default": "single-content"
}Structure
There are two top-level keys, sidebars and default:
sidebarsis an array of configuration objects, one for each sidebar.defaultis the slug of the sidebar that should be used if none of the specified conditions are met. If not specified, no sidebar is rendered for contexts that don't meet any of the conditions.
About the sidebars array
Order within the sidebars array is important. The sidebar used is the first
one whose conditions match the current context. The <RightRail /> component
will not render multiple sidebars in the same context, except when the sticky
sidebar is requested.
Conditions
The conditions object within each individual sidebar configuration can be
either an array or an object.
If it is an array, each value in the array is a PHP function that returns a truthy value when the sidebar should render in the given context.
If it is an object, each key is a PHP function that returns a truthy value and the value is a string that will be passed to the function as an argument.
Sticky Sidebar
If the append_sticky_sidebar key is set to true, the <RightRail />
component renders the sticky sidebar below the sidebar for the current context.
The sticky sidebar is not configured in right-rail.json; it comes from the
pmc-sticky-sidebar plugin.
If no default sidebar is specified and no configured sidebar matches the current context, the sticky sidebar is not rendered.