• Hari

    (@craftisco)


    HI,
    I was reading through your article and the below was mentioned:
    Therefore, if you have no items to display, WordPress will end up displaying ALL your pages!!

    If you don’t want this, you must set the fallback argument to be a null string.

    wp_nav_menu( array( ‘theme_location’ => ‘primary-menu’, ‘fallback_cb’ => ” ) );

    I think my menu issue is related, since I dont have soething for the logged out users, the menu seems to blow with all pages visible.

    Could you kindly let me know where to set this particular code?
    wp_nav_menu( array( ‘theme_location’ => ‘primary-menu’, ‘fallback_cb’ => ” ) );

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author HelgaTheViking

    (@helgatheviking)

    Hi there. It’s not possible for me to say exactly as it’s wherever your theme is calling wp_nav_menu()… that’s frequently in the header.php template, but depends on the theme.

    However, it just occured to me that you could possibly filter wp_nav_menu_args see docs

    That means you could possibly drop the following snippet into your theme’s functions.php or add it via the Code Snippets plugin:

    
    function modify_nav_menu_args( $args ) {
        $args['fallback_cb'] = '';
        return $args;
    }
    add_filter( 'wp_nav_menu_args', 'modify_nav_menu_args' );
    

    Keep in mind this wasn’t tested and it should apply to every menu. If you don’t want that you might need to apply some conditional logic.

    Hope it helps.

    clicotop

    (@clicotop)

    Hello,

    I put the code but not working to.

    I have the template SweetJane, but not working 🙁

    Can you help me?

    Have you a skype or email for support? thx

    Plugin Author HelgaTheViking

    (@helgatheviking)

    @clicotop You should probably have created your own thread because I have no idea what you mean by “not working”. What is are you expecting to happen? What is happening instead? This is the only forum for support for my free plugins.

    clicotop

    (@clicotop)

    Hello

    the probleme, i active your pluggin, but nothing appears in my back office when I am in my menu settings…

    where can this come from?

    Thanks a lot

    check screenshot:
    https://snipboard.io/Qj7wDA.jpg

    Plugin Author HelgaTheViking

    (@helgatheviking)

    FAQ #1 https://wordpress.org/plugins/nav-menu-roles/#i%20don%27t%20see%20the%20nav%20menu%20roles%20options%20in%20the%20admin%20menu%20items%3F

    It’s a conflict. My list of known conflicts is out of date, but it is almost assuredly with whatever theme/plugin is adding the extra fields you do have.

    The need to update and add their custom fields to the core WordPress 5.4 hook wp_nav_menu_item_custom_fields for compatibility…. or at a minimum ensure they have that hook in their custom Walker.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Restrict role not working’ is closed to new replies.