WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The below is the menu code used in the default WordPress theme of "Allure Real Estate Theme for Placester".

     `<li><a href="/">Home</a></li>
     <li><a href="<?php echo @get_permalink(get_page_by_title('About')->ID); ?  


     <li><a href="<?php echo @get_permalink(get_page_by_title('Search')->ID); ?

     <li><a href="<?php echo @get_permalink(get_page_by_title('Blog')->ID); ?   

     <li><a href="<?php echo @get_permalink(get_page_by_title('Contact')->ID); ?

     <li><a href="<?php echo @get_permalink(get_page_by_title('Testimonials')->ID);   

How can I create a sub-menu in any one of the main menu items in the above code?

share|improve this question

A sub-menu generally is made by adding another ul/li elements inside an li, like this:

<ul>   <!-- Menu -->
    <li>Menu item 1</li>
    <li>Menu item 2</li>
    <li>Menu item 3
        <ul>  <!-- Sub Menu -->
            <li>Sub item 1</li>
            <li>Sub item 2</li>

But if you want some dropdown menu, you have to add some css, so that the submenu is hidden, and when you hover on the li with the submenu, you show the submenu.

I don't know that theme but it seems to me they don't have css for that.

The menu is build directly in the code? It's not using Wordpress Menus?

If you give a link of your site, I can help you with the css.

share|improve this answer

Is this menu hard-coded? In that case you might consider replacing this menu with an menu filled by WordPress, so you can add menu items and submenu items from within de admin.

For that, add the following code to your functions.php:

register_nav_menu( 'your-menu', __( 'Your Menu' ) );

And where your menu is now, place the following code (deleting the menu you have now):

wp_nav_menu( array( 'theme_location' => 'your-menu' ) );

Now the menu you select in the menu settings area will be shown as your menu.
And the submenu items you have added there will be added too.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.