How to Add Home Icon to Genesis Framework Breadcrumb

In this tutorial, we’ll show you how to replace the ‘Home’ text in breadcrumb of Genesis Framework to a nice home icon. Genesis has genesis_home_crumb and genesis_breadcrumb_args to allow users to customize the output of the breadcrumb.

To replace the default ‘Home’ text with the home icon, first you’ll need to register any icon font set such as Font Awesome, Genericons, Dashicon, or an icon font of your own choice.

Here, we’ll be using Dashicons. WordPress has already bundled the Dashicons icon font in the core so you’ll need to enqueue it using the following code.

1 2 3 4 5 6 7
<?php
//* Enqueue Dashicons icon font
add_action( 'wp_enqueue_scripts', 'afn_dashicons_icon_font' );
function afn_dashicons_icon_font() {
wp_enqueue_style( 'dashicons' );
}
view raw functions.php hosted with ❤ by GitHub

The code above should go into your child theme’s functions.php file. Next, we’ll use genesis_home_crumb filter to replace the default texts with our home icon. Also, we use home_url() here to automatically link the icon to the front page of our site. The code below also belongs to functions.php file.

1 2 3 4 5 6 7 8
<?php
//* Replace 'Home' text with a home icon in Genesis Framework breadcrumb
add_filter ( 'genesis_home_crumb', 'afn_breadcrumb_home_icon' );
function afn_breadcrumb_home_icon( $crumb ) {
$crumb = '<a href="' . home_url() . '" title="' . get_bloginfo('name') . '"><i class="dashicons dashicons-admin-home"></i></a>';
return $crumb;
}
view raw functions.php hosted with ❤ by GitHub

As you can see, dashicons dashicons-admin-home is the class of our home icon. For Dashicons, you can get this from Dashicons’s official page. You need to use the right class here for the home icon and in case you want to use different icon or want to use other set of icon font, make sure to change class as well.

Now, please refresh your browser and you’ll see a nice home icon in the breadcrumb.

Genesis Framework breadcrumb

Next, if you want remove the ‘You are here’ texts, that can be done using genesis_breadcrumb_args filter. Here’s a snippet you can:

1 2 3 4 5 6 7 8
<?php
//* Remove 'You are here' texts in Genesis Framework breadcrumb
add_filter( 'genesis_breadcrumb_args', 'afn_breadcrumb_args' );
function afn_breadcrumb_args( $args ) {
$args['labels']['prefix'] = '';
return $args;
}
view raw functions.php hosted with ❤ by GitHub

And here’s after we’ve removed the default ‘You are here’ texts:

Genesis home icon

In case you want to change thr color of the icon to match the design of your theme, that can easily be done by targeting the right class. Here’s an example:

1 2 3
.breadcrumb .dashicons.dashicons-admin-home {
color: #de696b;
}
view raw style.css hosted with ❤ by GitHub

The code above should go into your theme style.css file and it will simply change the color of the icon to red. In case some of you might wondering whether this tutorial can be used on other WordPress themes, then the answer is simply no because the genesis_home_crumb and genesis_breadcrumb_args belongs to Genesis Framework and therefore can only be used on Genesis Framework child themes.

Comments

  1. Ryan Biddulph says

    Nice coding insight here. I’m not a Genesis guy and love my theme but will reference this in the future, should I go down that road.

    • Editor says

      Hi,

      We just use the exact same code for our next project and it works perfectly. Just make sure you don’t copy the opening php tag. That might cause the error.

  2. Mi Muba says

    Very clean coding. My two blogs are on Genesis and was badly feeling to enhance the visibility of breadcrumbs on it. This will be of great help to me. I read a few more of your blog posts. They are very focused and its nice to see another great blog on WordPress techies. Thanks for sharing

  3. Rick R. Duncan says

    Great tutorial. I’ve made other Genesis customizations to their breadcrumb but never replaced the word home with an image/icon. I grabbed your code and edited it to work with font awesome and everything works perfectly.

    Thanks for the tutorial.

    -rd

  4. Areesha Niir says

    Hello Admin,

    First time I visit this blog. and this is really great coding. Home icon is looking good instead if Text in Breadcrumb.
    Thanks for sharing such clean cod.

    Areesha Noor!

  5. Bilal Ahmad says

    I really appreciate your efforts. Very well explained. Just like the wpbeginner your blog is going to become another source for working and accurate coding related tutorials. Well done.

Leave a Reply

Your email address will not be published. Required fields are marked *