How to Fetch the WordPress Menus in Frontity
- Post AuthorBy Michael Burridge
- Post DateWed Jan 27 2021
One of the most frequently asked questions in the Frontity community forum is: how do you use the WordPress menus in Frontity?
Why does this question come up so often? Well, WordPress users are used to being able to edit the menus within the WordPress admin pages and seeing the navigation change in the front end in the WordPress theme.
Developers creating Frontity themes instead of WordPress themes would like the same, or similar, functionality. At the moment the navigation is usually hard-coded into frontity.settings.js
or the theme’s index.js
to be stored in the state.
While this is fine for developers it’s not so great for content creators and editors who may lack coding skills.
In this talk Michael provides a solution to this frequently asked question. Using the ‘WP-REST-API V2 Menus’ plugin and a handler in the Frontity theme, he shows how developers can have the best of all worlds allowing content creators/editors to update the menus in WordPress, yet still display those menus in the Frontity site.
We’re trying a new format in this video. Instead of the conversational style adopted by JuanMa and Michael in previous episodes of Frontity Talks we’re trying a more presentational format with just one presenter. We think this might be better for presenting technical topics. Let us know what you think in the video comments. Do you prefer this format or should we go back to the more conversational format?
Time poor? Jump straight to the part of the video that interests you:
00:10 Preamble
01:06 Introducing the topic
02:37 The Plugin
06:01 Creating the handler
15:45 Using a property for the slug
18:09 Displaying child menus
20:59 Summary
Links referenced in the video
- Repo: https://github.com/frontity-demos/frontity-examples/tree/master/fetch-menu-from-wp
- Plugin: https://wordpress.org/plugins/wp-rest-api-v2-menus/
- Theme Unit Test: https://codex.wordpress.org/Theme_Unit_Test
We hope you enjoy this episode of the Frontity Talks and that you find it useful. If you want to see any particular Frontity related topic covered then please suggest it in the video comments or use the hashtag #AskFrontity on Twitter.
If you’ve missed any of the earlier episodes of Frontity Talks and want to catch up, you can find them all in this Youtube playlist.
Don’t forget to subscribe to our channel and tap the notification bell 🔔 to get notified when new videos are out!
Comments? Suggestions? Join the conversation here.
- Post TagsDevelopment, DevRel, Frontity Talks