Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

Template Name: Package
if (is_page('business') || $post->post_parent=="17")
else if (is_page('residential') || $post->post_parent=="19")
share|improve this question

1 Answer 1

get_ancestors() will return the full parent page ID hierarchy for a given page ID which you could check against.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.