• I’ve been using this beauty of a code snippet for when I want to show the page’s title if it’s a parent page and show the parent title when on a child page:

    <?php
    $parent_title = get_the_title($post->post_parent);
    echo $parent_title;
    ?>

    However, only when on a child page of that parent, I would like the child page’s title to show underneath.

    So, if the page parent was “About Us” and its child page was “History”

    I’d like the page to show below when on the About Us page:

    About Us

    And this when on the History page:

    About Us
    History

    How do I do this?

  • The topic ‘Show Child Title only when on a child page’ is closed to new replies.