How to create a child menu in a different place in wordpress

I have a main menu and it has a dropdown submenu. I also have to show the same submenu below main menu along with the dropdown and it will be always there. Please see the picture to get an overview.

I was thinking of using the page_id in each page and get children of that page and show them as that submenu. But problem arises when I am inside a child page. Then I cant get the children because the page_id is different. This also causes a problem for blog. Is there any best way to achieve this? Thanks in advance.

Read More

enter image description here

Related posts

Leave a Reply

2 comments

  1. You can achieve this in two ways:

    • With the help of jQuery you can get the child menu and populate that
      child menu in desired div (i.e below the main menu)
    • Even if you are in child page you can get the parent page id and
      selects his child page again with some checks.

    jQuery is simple solution in my opinion. Example is given below.

    JSFIDDLE

  2. Please check these lines.

    <?php
    
    global $post;     // if outside the loop
    
    if ( is_page() && $post->post_parent ) {
        // This is a subpage
    
    } else {
        // This is not a subpage
    }
    ?>