0

I have developed a theme which has a parent menu and a sub-menu. It looks something like:

Main menu              ==> category | price | depot

sub menu for category  ==> tag| name | date (show/hide)
sub menu for price     ==> currency | date (show/hide)
etc...

I am using a redirect template that redirects automatically to first tab of child menu when i click on parent menu. Ie if I open :

http://host/category 

it will redirect to:

http://host/category/tag

Question

I would like to get the parent's menu_order from child menu. ie , when loaded:

http://host/category/tag

I want to get the order (0,1,2...) of the parent ie "category" tab. How is this done in WP?

0

I solved it using 'menu_order':

function parent_menu_order($post) {
   if( isset($post->post_parent) ) {
      if($post->post_parent == 0) {
         return $post->menu_order;
      }// if no parent,  return it itself
      $post_data = get_post($post->post_parent);
      return $post_data->menu_order;
   } else {
      return -1;
   }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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