![]() ![]() You can directly add this menu shortcode to your pages, posts, widgets. ![]() Eg: Īdvertisements Add Menu Shortcode in Posts | Pages | Widgets | Template You can add a class name for the menu by using attribute class="your-class-name" in the shortcode. So your menu shortcode will be something like Copy that menu name from there and add it to your shortcode. Just go to Appearance > Menus and find the menu name as shown in the image below. Advertisements Add Menu Name in The ShortcodeĪdvertisements Now your shortcode is ready, but it will only work if you will add the menu name to it. That means you can use shortcode to display menus in your pages, posts, widgets and templates. You can add a menu name in this shortcode with the name attribute. The shortcode requires your menu name as a parameter to display the correct menu. =Īdd_shortcode('addmenu', 'diwp_menu_shortcode') I have written a detailed article on creating WordPress shortcodes with parameters, where I have outlined how to pass parameters in shortcode. This code will create a shortcode in your WordPress theme.īasically in the below code, I have just created a shortcode with parameters, and then use those parameters with WordPress wp_nav_menu() function. Create WordPress Shortcode For MenuĪdd the code snippets given below in your theme’s functions.php file to create a shortcode for the menu. Add menu shortcode in a page, post, widget, or template.Add Menu name in the shortcode to display menu items.Creating a WordPress shortcode for a menu is super easy, And I am going to tell you the step-by-step process in detail further in this article. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |