Community Forums › Forums › Archived Forums › Design Tips and Tricks › Optimized Studiopress' breadcrumbs to remove the double 'Home' tag as needed
Tagged: 'double Home', breadcrumbs
- This topic has 1 reply, 2 voices, and was last updated 9 years, 10 months ago by nciske.
-
AuthorPosts
-
June 10, 2014 at 12:57 pm #108795JamesmMember
Hi, again; still working on Ambiance-Pro and one of the items on my punch list was to get rid of the double 'Home' tags that shows ups as Home/Home/Child Page when a user clicks on a child page in the menu and presumably you have gone into the functions.php file and changed the $args['depth'] on the primary at least to something other than a '1'.
It is simply done as follows, showing breadcrumbs first:
//* Modify Home breadcrumb link.
add_filter ( 'genesis_home_crumb', 'sp_breadcrumb_home_link' ); // Genesis >= 1.5
add_filter ( 'genesis_breadcrumb_homelink', 'sp_breadcrumb_home_link' ); // Genesis =< 1.4.1//* Make sure each branch of the if each tree has a function call; doesn't work w/o it
if ( is_home() ) { // This is a homepage function sp_breadcrumb_home_link( $crumb ) { return preg_replace('/href="[^"]*"/', 'href="http://example.net/"', $crumb); } } else { //* This is not a homepage function sp_breadcrumb_home_link( $crumb ) { return preg_replace('/href="[^"]*"/', 'href="http://example.net/home"', $crumb); } }
//* Modify breadcrumb arguments. Then I remove 'Home' value from the first argument.
add_filter( 'genesis_breadcrumb_args', 'sp_breadcrumb_args' );
function sp_breadcrumb_args( $args ) {
$args['home'] = '';
$args['sep'] = ' / ';
$args['list_sep'] = ', '; // Genesis 1.5 and later
$args['prefix'] = '<div class="breadcrumb">';
$args['suffix'] = '</div>';
$args['heirarchial_attachments'] = true; // Genesis 1.5 and later
$args['heirarchial_categories'] = true; // Genesis 1.5 and later
$args['display'] = true;
$args['labels']['prefix'] = 'Here We Are: ';
$args['labels']['author'] = 'Archives for ';
$args['labels']['category'] = 'Archives for '; // Genesis 1.6 and later
$args['labels']['tag'] = 'Archives for ';
$args['labels']['date'] = 'Archives for ';
$args['labels']['search'] = 'Search for ';
$args['labels']['tax'] = 'Archives for ';
$args['labels']['post_type'] = 'Archives for ';
$args['labels']['404'] = 'Not found: '; // Genesis 1.5 and later
return $args;
}//* next I'm going to attempt to clean it up and by putting a fake 'Home' in line somehow so that when user is on the Home page breadcrumbs will show a Home, but will not show a double Home when clicking on a Home child.
http://marlow-stepan.org/June 18, 2014 at 10:18 pm #110492nciskeMemberThis seems to do the same thing with far less code:
function maybe_remove_breadcrumb_home_link( $crumb ){ global $post; if ( is_singular( 'page' && $post->post_parent == get_option('page_on_front') ) ) return ''; return $crumb; } add_filter ( 'genesis_home_crumb', 'maybe_remove_breadcrumb_home_link' );
Nick Ciske | https://luminfire.com/ | @nciske
Did I help you? Say thanks: http://bit.ly/1lahwy0 -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.