Optimized Studiopress' breadcrumbs to remove the double 'Home' tag as needed

Community Forums Forums Design Tips and Tricks Optimized Studiopress' breadcrumbs to remove the double 'Home' tag as needed

This topic is: not a support question

This topic contains 1 reply, has 2 voices, and was last updated by  nciske 4 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #108795

    Jamesm
    Member

    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/
    #110492

    nciske
    Participant
    Post count: 55

    This 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 | http://thoughtrefinery.com/ | @nciske
    Did I help you? Say thanks: http://bit.ly/1lahwy0

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

You must be logged in to reply to this topic.