Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #28812

    I’ve got a plugin which creates several custom post_types. The breadcrumbs don’t work properly as they do not show the parent (archive) page. Most other themes and plugins I’ve used that generate breadcrumbs will work properly with custom post_types so long as in the custom post function you have 'has_archive' => true,, which I do.

    I know this is a shot in the dark, but any ideas? It looks like framework/php/class-breadcrumb.php includes a section designed to find the proper breadcrumb for custom post_types, but it isn’t working in my case.

    #138709

    I think Kriesi’s breadcrumb is not flexible enough for a custom post type but you can rewrite the code a bit. Open up wp-contentthemescoronaframeworkphpclass-breadcrumb.php and replace

    if($postType == 'post')
    {
    $ID = $category[0]->cat_ID;
    echo get_category_parents($ID, TRUE, $markup, FALSE );
    }
    else if($postType == 'portfolio')
    {
    $terms = get_the_term_list( $post->ID, 'portfolio_entries', '', '$$$', '' );
    $terms = explode('$$$',$terms);
    echo $terms[0].$markup;

    }

    with

    if($postType == 'post')
    {
    $ID = $category[0]->cat_ID;
    echo get_category_parents($ID, TRUE, $markup, FALSE );
    }
    else
    {
    $taxonomies = get_object_taxonomies($postType);
    $excluded_taxonomies = apply_filters('avf_exclude_taxonomies', array('post_tag','post_format'));
    $terms = '';

    if(!empty($taxonomies))
    {
    foreach($taxonomies as $taxonomy)
    {
    if(!in_array($taxonomy, $excluded_taxonomies))
    {
    $terms .= get_the_term_list( $post->ID, $taxonomy, '', '$$$', '' );
    }
    }
    }
    $terms = explode('$$$',$terms);
    echo $terms[0].$markup;

    }

    #138710

    Nice, thanks so much. That wasn’t exactly what I was looking for, but it led me in the right direction! My replacement ended up looking like this to get the parent/archive:

    $postType = get_post_type();

    if($postType == 'post')
    {
    $ID = $category[0]->cat_ID;
    echo get_category_parents($ID, TRUE, $markup, FALSE );
    }
    else if($postType == 'portfolio')
    {
    $terms = get_the_term_list( $post->ID, 'portfolio_entries', '', '$$$', '' );
    $terms = explode('$$$',$terms);
    echo $terms[0].$markup;

    }
    else
    {
    $post_type = get_post_type_object(get_post_type());
    echo '<a href="/' . $post_type->rewrite['slug'] . '">' . $post_type->labels->all_items . '</a>' . $markup;
    }

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Breadcrumbs with Custom post_types’ is closed to new replies.