Dropdown Menu – PHP Template Tag Usage Explained


Dropdown menu widget is so easy to use as a widget, but it also supports usage of PHP template tags. Using PHP code to insert the menu, you can easily add menus to your theme as many times as you like. In this post i will give you different code snippets to add the widget to your theme.

[toc type=”regular”]

Default usage

Adding dropdown menu widget using php is so easy. If you are going to add just one menu, things get a lot easier. All you have to do is to insert:

<?php shailan_dropdown_menu( ); ?>

somewhere in your header.php template. This is the default usage. This template tag uses settings page to get the necessary information. So after you add this code, you can easily change your menu options in the Dropdown Menu Widget options page.


Adding pages menu

To add a dropdown menu of your pages, you can use:

<?php shailan_dropdown_menu( array( 'menu' => 'pages' ) ); ?>

code. This snippet will get all the other data from the template tag options page except the menu type.


Adding categories menu

To add categories dropdown, you can use:

<?php shailan_dropdown_menu( array( 'menu' => 'categories' ) ); ?>

code. This snippet will also get all the other data from the template tag options page except the menu type.


Adding a custom menu using php code

To add a custom menu you created you need to set menu variable to either its ID or its name. Here are some examples:

<?php shailan_dropdown_menu( array('menu'=>'Katalog') ); // Adds a custom menu named Katalog ?>

<?php shailan_dropdown_menu( array('menu'=>'439') ); // Adds a custom menu with id 438 ?>

You can add as many as you like. There is no limit on the number of menus you can add.


Full arguments template

If those are not enough for your requirements here is the full arguments list. You can create many different menus using this argument template. Just change the variables as you need:

<?php // SETUP
$args =array(
	'menu' => 'pages',			// Menu type pages | categories | menuID | menu name
	'exclude' => '21,35,438',	// IDs of pages to be excluded
	'login' => true,			// Display login/logout link?
	'admin' => false,			// Show site admin link?
	'vertical' => false,		// Display vertical?
	'home' => true,				// Display home link?
	'align' => 'right',			// Align left | center | right
	'width' => '500'			// Width of menu
shailan_dropdown_menu( $args ); ?>



Dropdown menu widget allows you to easily manage your menus. It automatically generates menu code, effects and even CSS styles. All you need is to add it and then edit your menu as you like. Using template tag’s powers, now you can add multiple dropdown menus to your site, even if you don’t have any sidebars. Here i showed you most common uses of the template tag. I hope you found it useful.

NOTE: If you have any ideas, any points that need improvements, please leave your comment below.

21 thoughts on “Dropdown Menu – PHP Template Tag Usage Explained”

  1. Hi,

    I have 2 questions – 1.) The theme I picked in the plugin settings is white font, however, I am seeing black. Can you help with this?

    2.) How do I increase spacing between the menu columns?

    1. 1. Remove id="pagemenu" from your header.php file.
      2. You can use something like this in style.css to increase paddings of link elements:

      body div#shailan-dropdown-wrapper--1 ul.dropdown li a {
      padding: 12px 23px;

  2. I dont know what I did, but when i click on *Home* on the top menue it tells me “oops page cannot be found” I tried changing themes but it still the same. I need to fix it so when I click on *Home* it could take me or my readers to my front page or my post page. Im not trying to create static page. Can anyone help me fix this problem?

  3. I am working with “martable” theme & implemented WooCommerce plugin along with your widget for e-comm website, i want my product categories to be shown in a specific menu item. How can we do that?

  4. I am using the ‘pages’ ) ); ?> tag inside a text widget, and its only showing ‘pages’ ) ); ?>.

    Where am I missing?

Comments are closed.