• Resolved franknl

    (@franknl)


    I would like logged out users to not see any menu item.
    The FAQ already covers this usecase. And it gives a solution, add “wp_nav_menu( array( ‘theme_location’ => ‘primary-menu’, ‘fallback_cb’ => ” ) );”.

    Since I am unexperienced in building WordPress sites…where/how should I add this line of text?

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

    (@helgatheviking)

    You don’t add the line so much as modify the fallback_cb parameter wherever the wp_nav_menu() function is called in your theme.

    It’s specific to your theme so I can’t tell you where it exists though the main menu is commonly in the header.php file.

    Alternatively, it has just occurred to me that we can filter all the nav menu args.

    Untested (so please test before using in production) but the following snippet should turn off fallback menus for *all* menus on you site. You would need to add it to your theme’s functions.php file or add it to via the Code Snippets plugin.

    /**
     * Disables the fallback page menu for all menus
     *
     * @param array $args Array of wp_nav_menu() arguments.
     * @return array
     */
    function kia_nav_menu_args( $args ) {
    	$args['fallback_cb'] = '';
    	return $args;
    }
    add_filter( 'wp_nav_menu_args', 'kia_nav_menu_args' );

    Hope it helps!

    Thread Starter franknl

    (@franknl)

    It worked perfectly, thanks!!
    Very easy to implement.

    Plugin Author HelgaTheViking

    (@helgatheviking)

    Glad to hear it. Yes, I think this is an easier method.. I’ll try to update the FAQ eventually.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘All menu items display’ is closed to new replies.