Skip to content

Instantly share code, notes, and snippets.

@nicomollet
Last active August 29, 2015 14:08
Show Gist options
  • Save nicomollet/153d683ebbdf659f76ad to your computer and use it in GitHub Desktop.
Save nicomollet/153d683ebbdf659f76ad to your computer and use it in GitHub Desktop.
Wordpress Breadcrumb Trail for Custom Post Type
<?php
// Adds a custom breadcrumb item at position 1 (just after Home >)
function custom_breadcrumb_trail($trail ){
if( is_tax('custom_taxonomy') ){
$post_type_obj = get_post_type_object('custom_post_type');
$title = apply_filters('post_type_archive_title', $post_type_obj->labels->name );
$newtrail = array( '<li><a href="'.get_post_type_archive_link( 'custom_post_type' ).'">'.$title.'</a></li>' );
array_splice( $trail, 1, 0, $newtrail ); // splice in at position 1
}
return $trail;
}
add_filter('breadcrumb_trail_items','custom_breadcrumb_trail');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment