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

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.

Leave a Reply

Your email address will not be published. Required fields are marked *