If Child or Grandchild of Page

Question

I’m serving a different header in WordPress depending what section you are within the site, ‘residential’ , ‘business’ or other by using the following code. Although i need to extend it to work with grandchildren as well, so another level down.

<?php
/*
Template Name: Package
*/ 
if (is_page('business') || $post->post_parent=="17")
{
get_header('business');
}
else if (is_page('residential') || $post->post_parent=="19")
{
get_header('residential');
}
else 
{
get_header();
}
?>
0
Roy Barber 1 year 2020-07-11T06:10:22-05:00 0 Answers 50 views 0

Leave an answer

Browse
Browse