Breadcrumb trail (3 posts)

  1. webwitch
    Posted 6 years ago #

    I am using the Indy Premium theme which has a basic breadcrumb trail in page.php ie the home page and the title of the page/post as below:

    <span class="breadcrumbs">/">Home » <?php the_title(); ?></span>

    I would like to include the complete path with the parent page and subsequent child pages.

    How can I customise the existing code to include a complete path?

    Many thanks.

  2. Simon Fairbairn
    Posted 6 years ago #


    You could try testing the post to see if it has ancestors, then, if so, retrieve the post titles of those ancestors and display them.

    Example only.

    // If you're using the_title();, I'm assuming you're in the loop
    $pageID = get_the_ID();
    if (get_post_ancestors($pageID) != '') {
     $post = get_post(get_post_ancestors($pageID));
     $title = ">> ".$post->post_title;
    <span class='breadcrumbs'> > Home <?php echo $title; ?> >> <?php the_title(); ?></span>

    This is off the top of my head, and would need to be improved (it only checks for the immediate parent, for a start, and mixing up the display of >> with the title of the parent is pretty klunky).

    Might be easier just to grab a plugin to do it all for you:


  3. webwitch
    Posted 6 years ago #

    thanks for your help - i think i'll follow your advice and look for a plugin!

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.