• KyeLani

    (@kyelani)


    Hello,

    I’m building a child theme and I’ve created four custom, section-specific menus, which are displayed in a collection of sidebars that each correspond with a section of a web site.

    I have a function to check if the current page is a top level page or a child of that page and display the appropriate section-only menu in the sidebar and, for two of the sections, it’s working perfectly. For the other two, however, it is not working at all, in fact, I’ve had to reassign the child pages in those two sections as top level pages in order for it to work!

    I couldn’t possibly be more frustrated (how CAN two be working and two not?!)

    Here’s my (intended) process…

    Each of the four top level pages calls its own sidebar, which contains:

    if (is_page('top-level-page') || is_child_of('top-level-page'))  :
    
    		dynamic_sidebar('this_sections_sidebar');
    
    endif;

    functions.php

    function is_child_of($page) {
    
    	$thispage = get_page_by_title($page);
    	if (is_child($thispage->ID)) {
    		return false;
    	} else {
    		return true;
    	}
    }

    To reiterate, this is working perfectly for two top level pages that both have child and grandchild pages, but it’s NOT working for two other pages which both have child pages (they (co)incidentally DON’T have grandchildren).

    When I removed the ‘Parent’ from the settings of the child pages in the sections that aren’t behaving as expected, the menus worked fine, which baffled me more than anything, because then they met NEITHER of the criteria in the IF statement!

    Here’s the WIP: http://previewmy.com/wh/.

    “Who We Are” and “What We Do” are working as expected. Clients and Resources are set up EXACTLY the same way and are not working (as you can see).

    Sorry if I haven’t provided enough information, happy to supply more if you can help.

    Thank you!

  • The topic ‘[Theme: Twenty Eleven] Custom menu and parent pages’ is closed to new replies.