Breadcrumbs are a helpful way for users to track their path through a website and understand its hierarchy. By default, many WordPress themes display “HOME” as the root element in breadcrumbs. However, you may want to change this to something more specific or suitable for your website.
This guide will show you how to change the “HOME” string in breadcrumbs using the astra_breadcrumb_trail_labels filter in your WordPress website.
We’ll provide step-by-step instructions and a code snippet to help you get started.
How to Change the “HOME” String in Breadcrumbs
Before you proceed, you should ensure that you have a WordPress website using the Astra theme and you have administrative access to your WordPress dashboard.
Then, you can follow the below steps to change the “HOME” string in breadcrumbs:
- Log in to your WordPress admin panel using your credentials.
- In the WordPress dashboard, go to “Appearance” and select “Theme File Editor.”
- In the Theme Editor, you should see a list of theme files on the right. Locate and select the `functions.php` file from the list.
- Inside the `functions.php` file, you can add the following code snippet:
add_filter( 'astra_breadcrumb_trail_labels', function( $args ) {
$args['home'] = __( 'Index', 'astra' );
return $args;
});
- This code uses the `add_filter` function to modify the “HOME” label in breadcrumbs to “Index.” You can replace “Index” with any text of your choice.
- After adding the code snippet, click the “Update File” button to save your changes.
Example: Let us consider your website has a page “Construction” as attached in this screenshot. Now, if you want to change the ‘HOME’ string in the breadcrumb to ‘New Flat’, you will need to replace ‘Index’ with ‘New Flat’ in the code snippet.
Then, your page would be like this.
Note: The above-attached custom code can be added via a child theme, Custom Layout, or code snippet plugin.
You have to be extra careful when editing theme files. Always back up your website or theme files before making any changes, and make sure you understand how to modify code.
If you have problems after making these changes, remove the code snippet from the functions.php file to revert to the original state.
The astra_breadcrumb_trail_labels filter is only for the Astra theme. If you use a different theme, check its documentation or support resources for similar functionality.