How to display a specific post type name in a breadcrumb

This is a classic failure to indent code leading to confusion issue.

If we reformat your code correctly we see:

function the_breadcrumb() {
    if (!is_home()) {
        echo "Start » ";
        echo '<a href="';
        echo get_option('home');
        echo '">';
        bloginfo('name');
        echo "</a> » ";
        if (is_category() || is_single() ) {
            the_category('title_li=');
            if (is_single()) {
                echo " » ";
                the_title();
            }
        } elseif (is_page()) {
            echo the_title();
        } elseif (is_single() && $post_type == 'partners') {
            echo "IS THIS WORKING?";
        }
    } elseif (is_home()) {
        echo "Start » ";    bloginfo('name');
    }
}

Now we can follow it appropriately. What’s happening is it’s entering the is_category || is_single() if statement, and executing that part first. Because the if statement succeeded, it never reaches your check later on.

But, even if it did, there’s a second problem, you’re checking $post_type, but where is this coming from? Nowhere is it declared as a global or assigned a value, it’s been plucked out of thin air.

So here is my alternative:

function the_breadcrumb() {
    if (is_home()) {
        echo "Start » ";
        bloginfo('name');
        return;
    }
    echo "Start » ";
    echo '<a href="'.home_url().'">';
    bloginfo('name');
    echo "</a> » ";

    // Check each case starting with the most specific down to the most generic
    global $post;
    $post_type="";
    if ( !empty( $post) {
        $post_type = $post->post_type;
    }
    if ( is_single() && $post_type == 'partners' ) {
        echo "IS THIS WORKING?";
    } elseif ( is_page() ) {
        echo the_title();
    } else if (is_category() || is_single() ) {
        the_category('title_li=');
        if (is_single()) {
            echo " » ";
            the_title();
        }
    }
}

Here I’ve used the global post object to get around the lack of a $post_type variable to compare against. I’ve also re-ordered the if statements from most specific to most generic. Finally I took the big if else on the is_home call and put it at the top and did a return, that way we don’t nest the code as much and it becomes more readable, and a comment for good measure. I also used home_url instead of get_option('home')

So in summary:

  • Always indent correctly. You have no excuses for not doing it, most editors will do this for you. If yours doesn’t, go grab sublimetext or another IDE like Komodo or PHPStorm.
  • Read your code from top to bottom and follow it in your head. It’s not hard and bugs like this become quite obvious very quickly. It also gets far far easier as you do it, eventually you won’t need to think about it at all, it’ll just happen automatically
  • Never put » in html, always use the entitycode else your html won’t validate