[resolved] Conditional Statement for Parent Pages Only? (3 posts)

  1. bunnyhello
    Posted 3 years ago #

    I have a template page I am working on for several different pages, some of which are parent pages, most of which are children and grandchildren.

    The parent pages don't have a title, the children and grandchildren do have the title.

    How would I write a conditional tag that would only call the <h1><?php the_title(); ?></h1> when the page is a child or grandchild?

    Thanks in advance!

  2. Michael
    Forum Moderator
    Posted 3 years ago #


    <?php if( $post->post_parent ) { ?>
    <h1><?php the_title(); ?></h1>
    <?php } ?>
  3. bunnyhello
    Posted 3 years ago #

    That was perfect! Thank you so much!

Topic Closed

This topic has been closed to new replies.

About this Topic