Dynamic Navigation
Dynamic Navigation replaces a selected placeholder in a classic WordPress menu with generated items. Use it for destination trees, product categories, featured content or a directory of posts. Ordinary menu links remain alongside the generated branch.
Requirements: WordPress 6.0 or later and PHP 8.0 or later. NaturesLens Core is optional. ACF is optional for the plugin; this example uses ACF to manage its content type, destinations and featured flag.
How it works
- Content: WordPress holds the terms, posts and custom fields.
- Source: a saved configuration selects a provider, filters the content and builds a hierarchy.
- Menu: the plugin replaces a placeholder during WordPress menu rendering. Bricks receives standard menu item objects, including their parent relationships.
The generated items are assembled when the menu renders; they are not a second set of manually maintained links in Appearance → Menus. Bricks controls styling, dropdowns and mobile interaction.
Use a Bricks Nav Menu element connected to a WordPress menu. A manually assembled Nav (Nestable) tree is a different content source and is not automatically populated by this plugin.
Build the featured-trips example
- Create a public post type for trips and a hierarchical destination taxonomy. In this demo ACF manages
pg_dnav_tripandpg_dnav_dest. - Add Europe → Finland, Europe → Spain and Africa → Botswana. Assign sample trips to the country terms.
- Add a true/false field named
pg_dnav_featured. Turn it on for the trips that should appear. - In Appearance → Menus, create a menu and add a parent custom link called Featured trips, URL
#. Under it add another custom link called Featured trips Placeholder, also URL#. - Open Appearance → Dynamic Navigation and add a source. Select this menu and its placeholder.
- Choose the Custom Post Type provider, the trips post type and Published status. Set Group By: Taxonomy, select the destinations taxonomy and preserve its hierarchy.
- In Query Builder add
pg_dnav_featured = 1, compare against a value, with Number as the value type. Choose ALL matching. - Order trip titles ascending. Leave Maximum Items at
0for unlimited. Set the item label template toExplore {title}and the URL template to{permalink}. Leave group labels and URLs at their defaults. - Save and inspect the preview. In Bricks, add a Nav Menu element, select this WordPress menu and style its normal menu, submenus and mobile controls.
When NaturesLens Core is active, the configuration lives under NaturesLens – Display & Navigation instead. Without Core, sources are under Appearance and tools under Tools → Dynamic Navigation.
Combine multiple sources in one menu
The expanded demo uses three independent sources in the same WordPress menu. Each source replaces a different placeholder below its own parent menu item.
- Featured trips: use the
pg_dnav_trippost type, filterpg_dnav_featured = 1, and group by the hierarchicalpg_dnav_desttaxonomy. The demo holds 20 trips: 18 featured trips, three per country, and two unfeatured trips. - Destinations: add a Destinations parent link and a child placeholder. Create a Taxonomy source for
pg_dnav_dest, with no root restriction and unlimited depth. It outputs the three continent terms and six country terms directly. - Resources: add a Resources parent link and a child placeholder. Create a Custom Post Type source for
pg_dnav_resource, grouped bypg_dnav_topic. Nine sample resources appear under three topics, with three posts in each.
The trip and resource post types, both taxonomies and the featured field are managed through ACF. Editors can add, rename, reclassify or unpublish the records; the generated branches follow the saved content after cache refresh. The ordinary menu links alongside them remain manually editable in Appearance → Menus.
Reuse the source on desktop and mobile
To use separate WordPress menus, add an equivalent placeholder to each. Enable CSS Classes under Screen Options in Appearance → Menus, then add dnav-placeholder-pg-featured-trips to each placeholder.
In the source choose All menus with matching placeholder and enter pg-featured-trips as the Placeholder key. Use Tools → Dynamic Navigation → Placeholder Matches to inspect which menu items will be replaced. An explicit key is easier to maintain than relying on title matching.
The source can be reused in separate menus with matching placeholders. The live demo uses one responsive WordPress menu: a wide grouped panel on desktop and an inline panel on phones.
Enable Use mobile label and enter {title} to remove “Explore” from the trip labels at widths of 768px and below. This label breakpoint is fixed in the plugin; the Bricks mobile-menu breakpoint is a separate setting.
Style the menu in Bricks
The demo uses a single Bricks Nav Menu element with the pg-dnav-menu global class. Featured trips opens one panel containing all the generated destination groups and trip links. On phones the panel expands within the page.
In the Nav Menu element, set Mobile menu: Never and enable Sub menu → Position: Static. That native Bricks setting makes the control toggle on click rather than hover. The class lays out the generated hierarchy as columns on desktop and a single column on phones. The descendant group toggles are hidden because their links are visible together.
Click the label or arrow to open or close the panel. Escape and clicking outside close it; keyboard users can tab through the destination and trip links. Moving the pointer out of the panel does not close a panel opened by click.
The styling is editable in the Bricks global class. It uses the Playground theme’s --pg-* values and the --pg-nav-surface variable. Map these to your own design system if you copy the class to another site.
Other ways to generate navigation
- Taxonomy provider: output terms directly. Choose a root term, whether to include it, depth, ordering, empty-term behaviour and term-field filters.
- Custom post types: output public posts, grouped by taxonomy, post parent, first letter or ACF field.
- Query Builder: combine ALL or ANY rules, compare a field with a value or another field, and use operators such as equals, greater than, contains, exists and IN.
- Ordering: sort posts by title, date, menu order, random order or metadata. Metadata can be treated as text, numbers, dates or datetimes. Taxonomy headings have separate ordering controls.
- Labels and URLs: use templates such as
{title},{slug},{permalink}and{acf.field_name}. The Insert placeholder picker shows tokens for the chosen source.
Excluded or filtered taxonomy terms are omitted. Surviving children can attach to the next surviving ancestor, so excluding a heading does not necessarily exclude its entire branch. Terms marked by the optional NaturesLens Term Exclusion Manager are also respected.
Updating content and checking caches
Change a sample trip’s Featured in navigation switch and save the post, then reload the demo. Only matching published trips should appear. Renaming a trip changes its generated label; assigning a different destination changes its grouping.
The plugin caches generated menu items for up to an hour and clears its cache on source changes and relevant post/term changes. It uses persistent object caching when available and WordPress transients otherwise. Tools → Dynamic Navigation provides cache and diagnostic controls.
Full-page caching is a separate layer: a page cache can continue serving old menu HTML after the source cache changes. The plugin has explicit FlyingPress purge support. For another page cache or CDN, configure its purge behaviour and check more than one page after a menu-changing edit.
Rules based on the current user, current language or a changing date need an appropriate cache strategy. This demo uses a shared featured flag only. Do not use the present implementation as an access-control mechanism or assume it partitions generated output by user or language.
If items are missing, check publication status, filter value and type, term exclusions, item limits and the selected menu/placeholder. If a placeholder remains visible, check that the source is enabled, the key matches and the Bricks element uses the configured WordPress menu.