Quantcast
Channel: Crunchify
Viewing all articles
Browse latest Browse all 1037

How to Modify / Customize Genesis Framework Breadcrumbs for your WordPress Blog?

$
0
0

Are you aware of Breadcrumbs? If you haven’t heard of breadcrumbs, it’s like a navigation on your site where it shows the hierarchy of the content you are looking at. For instance, a post will display breadcrumbs of which category, tag it has been grouped in.

If you are using WordPress Genesis Framework and want to have Breadcrumb similar to what I’ve on Crunchify.com then you follow below steps.

Step-1

  • Go to ‘Genesis‘ (left column) > ‘Theme Setting‘ page.
  • Navigate to Breadcrumbs setting and enable it as per your need

Genesis Framework Breadcrumbs setting How to Modify / Customize Genesis Framework Breadcrumbs for your WordPress Blog?

Step-2

Reposition breadcrumbs from before .entry to inside .entry (above title) on single Posts and static Pages. How to resposition breadcrumbs in Genesis?

Breadcrumbs display Before How to Modify / Customize Genesis Framework Breadcrumbs for your WordPress Blog?

Breadcrumbs customization tips display After How to Modify / Customize Genesis Framework Breadcrumbs for your WordPress Blog?

Add this code to Genesis Child theme’s functions.php file

//* Crunchify Tips: Reposition breadcrumbs from before .entry to inside .entry (above title) on single Posts and static Pages
add_action( 'genesis_before_content', 'crunchify_reposition_breadcrumbs' );
function crunchify_reposition_breadcrumbs() {
	if ( is_singular() ) {
		remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
		add_action( 'genesis_entry_header', 'genesis_do_breadcrumbs', 9 );
	}
}

Step-3

Modify breadcrumb arguments.

//* Crunchify Tips: Modify breadcrumb arguments
add_filter( 'genesis_breadcrumb_args', 'crunchify_custom_breadcrumb_args' );
function crunchify_custom_breadcrumb_args( $args ) {
	$args['home'] = 'Crunchify';   // Home Page
	$args['sep'] = '   ➢  ';  // My favorite arrow
	$args['list_sep'] = ', '; 
	$args['prefix'] = '<div class="breadcrumb">';
	$args['suffix'] = '</div>';
	$args['heirarchial_attachments'] = true; 
	$args['heirarchial_categories'] = true; 
	$args['display'] = true;
	$args['labels']['prefix'] = '';
	$args['labels']['author'] = 'Archives for ';
	$args['labels']['category'] = 'Archives for '; 
	$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: '; 
return $args;
}

Step-4

Truncate the title of Genesis’s breadcrumbs result. Here I’m showing only 60 characters from title. You need to customize genesis_single_crumb hook.

//* Crunchify Tips: Modify genesis_single_crumb hook - Applies to only Genesis Framework Breadcrumbs

add_filter( 'genesis_single_crumb', 'crunchify_custom_genesis_single_crumb', 10, 2 );
function crunchify_custom_genesis_single_crumb( $crumb, $args ){
	global $post;
	// if not a single post page, return default crumb markup
	if( ! is_singular( 'post' ) )
		return $crumb;
	
        $crumb = str_replace( single_post_title( '', false ), '', $crumb );

	$thetitle = single_post_title( '', false );
	$getlength = strlen($thetitle);
	$thelength = 60;    // Truncate Title to only 60 characters
	$crumb .= substr($thetitle, 0, $thelength);
	if ($getlength > $thelength) {
		$crumb .= ' ...';
	}

	return $crumb;
}

Have anything to add to this article? Please chime in and join the conversion.


The post How to Modify / Customize Genesis Framework Breadcrumbs for your WordPress Blog? appeared first on Crunchify.
Author: Arpit Shah


Viewing all articles
Browse latest Browse all 1037

Trending Articles