How to get MB Views to show the theme menu?

Support MB Views How to get MB Views to show the theme menu?Resolved

  • This topic has 2 replies, 2 voices, and was last updated 3 years ago by A.A..
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #35462
    A.A.
    Participant

    How can I get the menus I set up in the WordPress admin area to show up in the page template when I set MB Views to replace the whole content including the header and footer? Because the menu items do not show up in Insert Fields like the Site and User tags...

    Thank you.

    #35472
    Long NguyenLong Nguyen
    Moderator

    Hi,

    You can use the proxy mb. to run a PHP/WordPress function, refer to this documentation
    https://docs.metabox.io/extensions/mb-views/#running-php-functions
    https://developer.wordpress.org/reference/functions/wp_nav_menu/

    For example: {{ mb.wp_nav_menu() }}

    #35481
    A.A.
    Participant

    Thank you very much.

    I tried it and it works. And to show a specific menu, after trial an error, the following code worked for me:

    {% set args = { menu: 'Secondary Menu' } %}
    {% set menu = mb.wp_nav_menu( args ) %}

    The menu can be specified using the ID or name.

    So in the end, I used the bit of code you wrote to show the main/primary navigation, and then this second example to show the secondary menu.

    But I want to check, please: is this the correct way to target a specific menu on MB Views?

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.