I have one default page template that I wish to use for two scenarios. I'd prefer to use only one page template for the sake of simplicity for my client.
Here's what I'm trying to accomplish:
if parent_page OR if child-page without children {
display full-width-layout
}
if child page with children or if grandchild page {
display sidebar-menu-layout
}
Is this possible?
This is what I've tried so far:
if( is_page() && $post->post_parent > 0 ) {
//display sidebar-menu-layout
} else {
//display full-width-layout
}
It works so far as on top level pages, it displays full-width-layouts. But, what can I do to make sure that the sidebar-menu-layout is displayed on child-pages with children and on grandchile pages only? And for child-pages with no children, to display the full-width-layout.
Thanks in advance. I'm sure it has a simple solution, I'm just relatively new to WP so still trying to figure out what can and cannot be done.