Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #176275

    since I made a lot of changes to the avisio theme, I’m not shure if this is a default error or my own doing. As long as I’m on the overview page of a portfolio (e.g. the top menu item is highlighted. When I choose a portfolio entry (e.g., the highlighting is gone.
    Same thing happens with the blog. Overview page or choosing a category is fine (e.g. but selecting a post (e.g. “unlightens” the top menu.
    Can this be fixed?

    Regards Crazygirl

    • This topic was modified 4 years, 1 month ago by  crazygirl.

    Hello crazygirl!

    Unfortunately whats happening is just how WordPress sees those items. Posts and single portfolio entries are not child pages of any page so the menu wouldn’t be marked as such.



    Hi Devin,
    thanks for your reply. How wordpress handles this issue is very annoying. Have you never thought about a workaround?
    As you can see, I have implemented a sidebar menu for the portfolio ( It works with a function requesting the ancestors up to the top and then again listing the child elements. For each portfolio entry I added the id of the container page to the database by hand.
    I tried using this function in combination with a filter described by wordpress here: How to add a parent class for menu item this is the code:

    add_filter( 'wp_nav_menu_objects', 'add_menu_parent_class' );
    function add_menu_parent_class( $items ) {
    	$parents = array();
    	foreach ( $items as $item ) {
    		if ( $item->menu_item_parent && $item->menu_item_parent > 0 ) {
    			$parents[] = $item->menu_item_parent;
    	foreach ( $items as $item ) {
    		if ( in_array( $item->ID, $parents ) ) {
    			$item->classes[] = 'menu-parent-item'; 
    	return $items;    

    I tried to change it a little bit and to compare the retrieved items with my topmost parent page ID, which is the page that contains the portfolio entries, but it seems this is comparing apples and oranges.

    I try to adapt my wordpress theme to my needs but have only little knowledge of wordpress and php as well. So before searching for a solution for hours and hours maybe you could give me a hint where to search or just say leave it because it’s digging too deep into the core of wordpress.




    The main problem is that wordpress does not “know” the relations between portfolio pages and single portfolio entries. If you’re on a single portfolio entry page wordpress thinks it’s a standard post and it will mark the post categories as “current menu items” but it does not connect the entry to the portfolio grid page(s).


Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Top menu looses class .current-menu-parent when selecting portfolio item or post’ is closed to new replies.