Advanced Menu Widget Shortcode

Below, you’ll find a detailed guide on how to add the Advanced Menu Widget Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Advanced Menu Widget Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Advanced Menu Widget Plugin and the shortcodes it provides:

Plugin Icon
Advanced Menu Widget

"Advanced Menu Widget is a robust WordPress plugin that enhances your site's navigation. It offers customizable menus, allowing for a tailored user experience. A must for site optimization!"

★★★★☆ (25) Active Installs: 5000+ Tested with: 4.5.30 PHP Version: false
Included Shortcodes:
  • [advMenu]

Advanced Menu Widget [advMenu] Shortcode

The Advanced Menu Widget shortcode allows you to display a custom menu in your WordPress site. It provides options like ‘nav_menu’, ‘title’, ‘dropdown’, etc., to customize the output. This shortcode uses PHP function ‘amw_shortcode’ to generate an advanced menu. It takes various parameters, each offering unique customization. For example, ‘nav_menu’ specifies the menu to display, ‘title’ sets the title, ‘dropdown’ enables a dropdown menu, and so on. The output of the widget is stored in a buffer and returned as a string, allowing it to be inserted anywhere in your WordPress site.

Shortcode: [advMenu]

Parameters

Here is a list of all possible advMenu shortcode parameters and attributes:

  • nav_menu – Specifies the navigation menu to be displayed.
  • title – Sets the title of the widget.
  • dropdown – Determines whether the menu should be in dropdown format.
  • only_related – Shows only related or ancestor menu items.
  • depth – Controls how many levels of the menu to show.
  • container – Defines the HTML element to wrap the widget in.
  • container_id – Specifies the ID for the container element.
  • menu_class – Assigns a class to the menu for styling purposes.
  • before – Inserts content before the widget output.
  • after – Inserts content after the widget output.
  • link_before – Inserts content before each menu link.
  • link_after – Inserts content after each menu link.
  • filter – Adds a filter to the menu items to be displayed.
  • filter_selection – Specifies the criteria for the filter.
  • include_parent – Defines whether to include the parent item in the menu.
  • start_depth – Determines the starting level of the menu.
  • hide_title – Decides whether to hide the widget title or not.
  • custom_widget_class – Assigns a custom class to the widget.

Examples and Usage

Basic example – A simple usage of the ‘advMenu’ shortcode to display a navigation menu with the ID of 3.

[advMenu nav_menu=3 /]

Advanced examples

Using the ‘advMenu’ shortcode to display a navigation menu with various customization options. This example includes the menu with an ID of 5, a title, dropdown functionality, and a custom container ID.

[advMenu nav_menu=5 title="My Menu" dropdown=1 container_id="my-menu-container" /]

Using the ‘advMenu’ shortcode to display a related navigation menu with depth and custom CSS classes. This example includes the menu with an ID of 7, the only_related parameter set to 1, a depth of 2, and custom widget classes.

[advMenu nav_menu=7 only_related=1 depth=2 custom_widget_class="my-custom-class" /]

These examples demonstrate the versatility of the ‘advMenu’ shortcode, allowing you to customize the display of your navigation menus according to your specific needs.

PHP Function Code

In case you have difficulties debugging what causing issues with [advMenu] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'advMenu', 'amw_shortcode' );

Shortcode PHP function:

function amw_shortcode( $atts ) {
	$instance =	shortcode_atts(array(
					'nav_menu' 				=> '',
					'title' 				=> '',
					'dropdown' 				=> '',
					'only_related' 			=> '',
					'depth' 				=> '',
					'container' 			=> '',
					'container_id' 			=> '',
					'menu_class'			=> '',
					'before' 				=> '',
					'after' 				=> '',
					'link_before' 			=> '',
					'link_after' 			=> '',
					'filter' 				=> '',
					'filter_selection' 		=> '',
					'include_parent' 		=> '',
					'start_depth' 			=> '',
					'hide_title' 			=> '',
					'custom_widget_class' 	=> ''
				), $atts);

	ob_start();
	the_widget('Advanced_Menu_Widget', $instance, '' );
	$output = ob_get_contents();
  	ob_end_clean();

  	return $output;
}

Code file location:

advanced-menu-widget/advanced-menu-widget/advanced-menu-widget.php

Conclusion

Now that you’ve learned how to embed the Advanced Menu Widget Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *