0

problem is just the subpages do not show their parents...else is working absolutely fine

  function the_breadcrumb() {

   $sep = ' » ';

   if (!is_front_page()) {

    echo '<div class="breadcrumbs">';
    echo '<a href="';
    echo get_option('home');
    echo '">';
    bloginfo('name');
    echo '</a>' . $sep;

    if (is_category() || is_single() ){
       the_category('title_li=');
    } elseif (is_archive() || is_single()){
        if ( is_day() ) {
            printf( __( '%s', 'text_domain' ), get_the_date() );
        } elseif ( is_month() ) {
            printf( __( '%s', 'text_domain' ), get_the_date( _x( 'F Y', 'monthly archives date format', 'text_domain' ) ) );
        } elseif ( is_year() ) {
            printf( __( '%s', 'text_domain' ), get_the_date( _x( 'Y', 'yearly archives date format', 'text_domain' ) ) );
        } else {
            _e( 'Blog Archives', 'text_domain' );
        }
      }

      if (is_single()) {
        echo $sep;
        the_title();
      }

      if (is_page()) {
        echo the_title();
     }

      if (is_home()){
        global $post;
        $page_for_posts_id = get_option('page_for_posts');
        if ( $page_for_posts_id ) { 
            $post = get_page($page_for_posts_id);
            setup_postdata($post);
            the_title();
            rewind_posts();
          }
        }

      echo '</div>';
     }
    }
1
  • Inside your is_page() condition, check if the current page has parent ($post->post_parent), then if it has, get the parent page title from the parent page id and display it Commented Jun 10, 2015 at 6:56

1 Answer 1

0

I got it working as @Pieter suggested to check if page has parent or not.

Got the help from here Breadcrumb how i can display page title with parent > child title with permalink ? any Idea

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.