Breadcrumbs actions/filters
1/ Action that starts once breadcrumbs is shown on the page
Action name: 'etheme_page_heading'
Action usage:
add_action('etheme_page_heading', function() { ?> <div style="background-color: #000;color: #fff;line-height: 1;padding: 12px;"> <div> <marquee>This is custom text above page heading on each page has breadcrumbs</marquee> </div> </div> <?php }, 5);
Example: https://gyazo.com/e7a2df66ea87514dcb187864a7024fcb
Note: change the number after function to make it shown before/after breadcrumbs (higher is more under) -> https://prnt.sc/QQ0MYIjfwDvz
2/ Action that starts before breadcrumbs main content
Action name: 'etheme_before_breadcrumbs'
Action usage:
add_action('etheme_before_breadcrumbs', function() { ?>
<div style="text-align: center;">
<div>This is custom text above page heading on each page has breadcrumbs</div> </div> <?php }, 5);
Example: https://prnt.sc/aCd2UZvpr3_U
3/ Action that starts after breadcrumbs main content
Action name: 'etheme_after_breadcrumbs'
Action usage:
add_action('etheme_after_breadcrumbs', function() { ?>
<div style="text-align: center;"> <div>This is custom text below page heading on each page has breadcrumbs</div> </div>
<?php }, 5);
Example: https://prnt.sc/6B32qXXqf3El
#WooCommerce use-cases
4/ Filter to change title to title with endpoint on my account page
Filter name: 'etheme_breadcrumbs_page_title'
Filter usage:
add_filter ('etheme_breadcrumbs_page_title', 'et_breadcrumbs_title', 10, 1);
function et_breadcrumbs_title($subtitle){ if (!class_exists('WooCommerce')) return $subtitle;<br> if (is_account_page() && is_user_logged_in()){ if (is_wc_endpoint_url()){ global $wp; global $wp_query; $endpoint = WC()->query->get_current_endpoint(); $action = isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : ''; $endpoint_title = WC()->query->get_endpoint_title( $endpoint, $action ); if ($endpoint_title){ $subtitle .= ' - '.$endpoint_title; } } } return $subtitle; }
Example:
before -> https://prnt.sc/TwaT5sb1R-IM ( without endpoint after title )
after -> https://prnt.sc/Lgil50plBNv7 ( with page endpoint after title )
5/ Filter to remove shop step from breadcrumbs on product taxonomies pages (some users want to hide it or in some cases it is shown twice)
Filter usage:
add_filter( 'etheme_breadcrumbs_shop_step', '__return_false');
Example:
before -> https://prnt.sc/_jobUiKWBD4f ( shop step is shown )
after -> https://prnt.sc/0q5CLtn1NV1q ( shop step is not shown )