Addressing Child Page from Custom Menu
-
I build the website of an association with centers in different cities. Each city’s pages need their own sidebar. I want to program an automated solution where the editors dont need to select anything. I used the custom menu to structure the pages of the cities, but I cannot use the parenting of the pages themselves, because I want to avoid a domain.com/parent/child URL structure, but only have directly domain.com/page. And this is where my approach fails, because the custom menu hierarchy seems to be not addressable through $post->post_parent. I used this code:
<?php if ( $post->post_parent == '100' || is_page(100) ) { dynamic_sidebar( 'sidebar-2' ); } else { dynamic_sidebar( 'sidebar-1' ); } ?>
Any idea how I can still influence the output of different sidebars according to the custom menu hierarchy?
- The topic ‘Addressing Child Page from Custom Menu’ is closed to new replies.