I’ve been trying to work with Conditional Tags and cannot wrap my head around this problem. PHP novice here.
On sub-pages I need to display the parent page title as well as the page title. I have it working with this:
<h1><?php echo get_the_title($post->post_parent);?></h1>
<h2><?php the_title(); ?></h2>
But the problem I have now is that on the parent pages the page title is displayed twice, as the parent page title and the page title. Instead, when on a parent page, I need the h2
to display “Select a sub-page”, if there are child pages…or display nothing, if there are no child pages. Something like this is what I’m thinking is possible:
<h1><?php echo get_the_title($post->post_parent);?></h1>
<h2>
<?php
if is_parent_page_without_children() {echo '';} ;
elseif is_parent_page_with_children() {echo 'select a sub-page';} ;
else the_title();
?>
</h2>