AI Verified

Name

Better Breadcrumbs

About

Two main customizations are made:1. Changing the label of the 'home' breadcrumb based on the current page.2. Modifying the URL linked to the 'home' breadcrumb depending on the page.

Language

PHP

Rating

Voted: 0 by 0 user(s)

Codevault

Super-Snippet-Storage

Scroll down to see more snippets from this codevault.

Wordpress Compatability

The author has indicated that this snippet is compatable up to wordpress version: Not Specified

Our AI bot has checked this snippet is compatable up to wordpress version: 6.1

Code Snippet Plugin Sync

Free & Pro

Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.

Pro Only (Coming Soon)

You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.

History

Last modified:

23/11/2023

Important Note

This snippet has the following status:

AI Verified

This snippet has been tested by our AI bot, see any comments below.

AI Bot Comments:

Found 0 vulnerabilities

Better Breadcrumbs

 
                    
1/**
2 * WooCommerce Breadcrumb Customization
3 *
4 * This code customizes the breadcrumbs in a WooCommerce-powered WordPress site.
5 * Breadcrumbs are a navigational aid showing the user's current location on the website.
6 *
7 * Two main customizations are made:
8 * 1. Changing the label of the 'home' breadcrumb based on the current page.
9 * 2. Modifying the URL linked to the 'home' breadcrumb depending on the page.
10 *
11 * Functions:
12 * - custom_woocommerce_breadcrumbs: Modifies the default breadcrumb labels.
13 * On the shop page, the 'home' breadcrumb is labeled 'Home'.
14 * On other pages, it's labeled 'Shop'.
15 *
16 *
17 * @author Mark Harris
18 * @version 1.0
19 */
20 
21add_filter("woocommerce_breadcrumb_defaults", "custom_woocommerce_breadcrumbs");
22function custom_woocommerce_breadcrumbs($defaults)
23{
24 if (is_shop()) {
25 $defaults["home"] = _x("Home", "breadcrumb", "woocommerce");
26 } else {
27 $defaults["home"] = _x("Shop", "breadcrumb", "woocommerce");
28 }
29 return $defaults;
30}
31 
32add_filter(
33 "woocommerce_breadcrumb_home_url",
34 "custom_woocommerce_breadcrumbs_home_url"
35);
36function custom_woocommerce_breadcrumbs_home_url($url)
37{
38 if (is_shop()) {
39 return get_home_url();
40 } else {
41 return get_permalink(wc_get_page_id("shop"));
42 }
43}

0

Related Snippets

Please see some snippets below related to this snippet..

General

Unverified

0

QuizLogic

Added: 4 months ago

Last Updated: 4 months ago

General

Unverified

0

GP - přidat tlačítko do navigace

Added: 9 months ago

Last Updated: 9 months ago

Generatepress - přidá tlačítko do navigace

General

AI Verified

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

General

AI Verified

21

Convert To WebP

Added: 9 months ago

Last Updated: 4 days ago

<p>Snippet to convert JPG / PNG / Gif to WebP automatically on upload. Used GD or ImageMagick</p>

WordPress Admin

AI Verified

5

Really Simple Duplications

Added: 9 months ago

Last Updated: 7 months ago

A snippet to duplicate posts and pages and CPTS.

General

AI Verified

2

WP-Admin ChatGPT

Added: 6 months ago

Last Updated: 4 months ago