• Hi,

    I’m trying to display the parent page before a subpage title, similar to how a bread crumb might work (though I don’t need them to be links):

    Main Page > Sub Page

    I’ve tried a few examples of code that I found in here when I searched for child_of functionality, but I guess I don’t know enough about php to get it working.

    The test site is up at: https://ideasconnect.callitest.com/services

    When a person clicks a page in the sidebar, I would like to show:

    Services > (Sub page)

    Thanks!

    -Zak

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter woodenpier

    (@woodenpier)

    I’m not after a breadcrumb plugin, I’m after a way to call the parent page with php so I can wrap it in an <h2> tag and show it in my default page template.

    https://codex.www.ads-software.com/Template_Tags/get_the_title

    <h2><?php if($post->post_parent) { echo get_the_title($post->post_parent).' > '; } ?><?php the_title(); ?></h2>

    Thread Starter woodenpier

    (@woodenpier)

    Thanks heaps,
    In the design, I need to show the sub-page as an h3 with a class after the Parent title (which is an h2) and if the page IS the parent page, then to have it show up as the h2.

    If we’re on a sub page:
    <h2>Parent Page</h2><h3 class=”page-title”>Sub Page</h3>

    If we’re on a parent page:
    <h2>Parent Page</h2>

    See on the testing site: https://ideasconnect.callitest.com/services

    how it works great (thanks!) for the sub pages, but it is showing the ‘sub-page’ class for the title if we’re on an outer page.

    I tried making an else statement, but I don’t know how to put the html into the echo output.

    i hope i understood this right:

    <?php if($post->post_parent) {
    echo '<h2>'.get_the_title($post->post_parent).'</h2><h3 class="page-title"> '.get_the_title().'</h3>';
    } else { echo '<h2>'.get_the_title().'</h2>'; } ; ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘custom child_of breacrumb-style page title’ is closed to new replies.