You can shortcode the site menu, the official name 'WordPress navigation menu', which you can set in the WordPress Appearance> menu, to make it possible to insert it anywhere on the page or anywhere you want.
Normally you do not need to put this navigation menu in a short code and you do not know why,Poly
To encode a navigation menu, you have to go through two steps: creating a custom menu and registering the created menu with the short code. All the code is WordPress
Create WordPress Custom Navigation Menu
First of all,
register_nav_menus( array(
'custom_menu' => 'Custom Menu',
) );
Make Menu Shot Code
You can now shortcode the created menu and register it. In fact, the method of short coding is very easy. If you enter the code as a basic type, you will see that all skins are ignored and positioned at the top of a certain skin. Therefore, if you input it in the following way, you can short code custom menu without error.
function get_menu($args){ $menu = isset($atts['menu']) ? $atts['menu'] : ''; ob_start(); wp_nav_menu(array( 'theme_location' => 'custom_menu', ) ); return ob_get_clean(); } add_shortcode('Custom_nav_menu', 'get_menu');
In the above code, the blue
Inside the code
wp_nav_menu(array( 'theme_location' => 'custom_menu', 'fallback_cb' => false, ) );
This way you can add it like a red part.
Available Attributes
Here are the codes you can use here: Since I have not used it all, but have consulted the official help, some of the code might be different from the description.
Enter the ID, slug, and name of the menu that you want to allow
The menu consists of
The menu consists of
Container around the menu
The above code. Sets the value to be called when there is no menu specified in the code. The default is a list of pages.
Let's put the text, images and icons freely with CSS
Over
As above, we specify the text before the link text.
As above, specify the text after the link text.
It is said that the menu is displayed or returned. The default value is
Determines the hierarchy of menus to load. here
Defines an instance of a custom worker class.
You define the location of the theme you want to use, just put in the name of the custom menu you want to use.
Wraps list items. The default value is
Menu
All of the available attributes are as above,WordPress