2

In the function wp_page_menu there is an auto-generated classes to the list elements and the function generates current_page_parent and current_page_ancestor to a parent menu item if I clicked a child menu item (I mean if the current page is the child menu element). So now why does WordPress generate two different classes for the same element.

enter image description here

1 Answer 1

4

These classes are explained a bit more on the page for wp_list_pages. But the words 'parent' and 'ancestor' give it away already.

A parent is an ancestor. A grandparent is also an ancestor, but not a parent.

If your hierarchy is only two deep, there will only be parents and children. So in that case all parents are ancestors and the two classes have the same effect. But when your hierarchy is deeper, the two classes get different meanings.

1
  • Yes, Thanks man. Actually wordpress didn't state that properly Feb 4, 2017 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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