I am trying to test for the child of a page. I have tried using this function found on the internet
function is_child($pageID) {
global $post;
if( is_page() && ($post->post_parent==$pageID) ) {
return true;
} else {
return false;
}
}
in the functions.php file ...but to no avail.
My problem is simple; if the page is a child of another page, do this, elseif, etc..
I have this conditional statement in my header.php so that when any child of a main page is clicked on, the submenu under the main "Image/Title" area stays consistent. Here's the code:
<?php if (is_page(13) || is_child(13) ) : ?>
<div class="subMenuContainer">
<?php wp_nav_menu( array( 'items_wrap' => '%3$s', 'container_class' => 'subMenu', 'after' => '<li class="menu-divider">|', 'theme_location' => 'sectors' ) ); ?>
</div><!-- end subMenuContainer -->
<?php elseif ( is_page(11) || is_child(11) ) : ?>
<div class="subMenuContainer">
<?php wp_nav_menu( array( 'items_wrap' => '%3$s', 'container_class' => 'subMenu', 'after' => '<li class="menu-divider">|', 'theme_location' => 'services' ) ); ?>
</div><!-- end subMenuContainer -->
<?php elseif ( is_page(17) || is_child(17) ) : ?>
<div class="subMenuContainer">
<?php wp_nav_menu( array( 'items_wrap' => '%3$s', 'container_class' => 'subMenu', 'after' => '<li class="menu-divider">|', 'theme_location' => 'mediacenter' ) ); ?>
</div><!-- end subMenuContainer -->
<?php endif; ?>
Any help on this would be most appreciated. I have tried and tried different approaches but nothing is working
Refer to this site: http://ahminc.com/ahm/services/