Wordpress - Check if is on child-page of a particular page
You can do that with $post->post_parent
. You will have to check if child page's parent is Services page. So this is how you will check it.
I assumed 123
in following code is page ID of your services page. Replace it with actual ID.
if ( 123 == $post->post_parent ) { ?>
<div class="col-md-2 col-sm-4">
<?php ci_e_logo('<h1 class="logo ' . get_logo_class() . '">', '</h1>'); ?>
</div>
<?php }
You can get the Post page / post name using this method.
$parent = array_reverse(get_post_ancestors($post->ID));
$page_parent = get_page($parent[0]);
echo $page_parent->post_name;
you can use the condition as per your requirements.
<?php
global $post;
if ( is_page('home') || is_page('services') ) { ?>
<div class="col-md-2 col-sm-4">
<?php ci_e_logo('<h1 class="logo ' . get_logo_class() . '">', '</h1>'); ?>
</div>
<?php }
elseif ( preg_match( '#^service(/.+)?$#', $wp->request ) ) { ?>
<div class="col-md-2 col-sm-4">
<?php ci_e_logo('<h1 class="logo ' . get_logo_class() . '">', '</h1>'); ?>
</div>
<?php
}
else { ?>
<div class="col-md-2 col-sm-4">
<h1 class="logo imglogo">
<a href="<?php echo esc_url( home_url( '/' ) ); ?>">
<img src="<?php echo get_bloginfo('template_directory');?>/images/picturehere.png" alt=""></a>
</h1>
</div>
<?php } ?>