In WordPress, breadcrumbs provide a navigational trail for users, enhancing the usability and SEO of your site.
If you’re using the MonaWP theme and want to replace its built-in breadcrumbs with those from popular SEO plugins like Yoast, All in One SEO, or Rank Math, this guide will help you achieve that by using WordPress filters and shortcodes.
Step 1: Install an SEO Plugin
First, ensure you have an SEO plugin installed that supports breadcrumbs. Some popular options include:
- Yoast SEO
- All in One SEO
- Rank Math
Step 2: Retrieve the Breadcrumb Shortcode
Each SEO plugin provides a shortcode for displaying breadcrumbs. Here are the shortcodes for some of the popular SEO plugins:
- Yoast SEO:
[wpseo_breadcrumb]
- All in One SEO:
[aioseo_breadcrumbs]
- Rank Math:
[rank_math_breadcrumb]
Step 3: Modify the MonaWP Breadcrumbs
You need to hook into the monawp_entry_breadcrumbs_html_filter
filter and replace the default breadcrumbs with the desired shortcode. Add the following code to your child theme’s functions.php
file or via a custom code inserter plugin like Insert Headers and Footers.
Example: Using Yoast SEO Breadcrumbs
// Define filter function to replace MonaWP breadcrumbs with Yoast SEO breadcrumbs
function replace_mona_breadcrumbs_with_yoast($html) {
// Use the Yoast SEO breadcrumb shortcode
return do_shortcode('[wpseo_breadcrumb]');
}
add_filter('monawp_entry_breadcrumbs_html_filter', 'replace_mona_breadcrumbs_with_yoast', 10, 1);
Example: Using All in One SEO Breadcrumbs
// Define filter function to replace MonaWP breadcrumbs with All in One SEO breadcrumbs
function replace_mona_breadcrumbs_with_aioseo($html) {
// Use the All in One SEO breadcrumb shortcode
return do_shortcode('[aioseo_breadcrumbs]');
}
add_filter('monawp_entry_breadcrumbs_html_filter', 'replace_mona_breadcrumbs_with_aioseo', 10, 1);
Example: Using Rank Math Breadcrumbs
// Define filter function to replace MonaWP breadcrumbs with Rank Math breadcrumbs
function replace_mona_breadcrumbs_with_rankmath($html) {
// Use the Rank Math breadcrumb shortcode
return do_shortcode('[rank_math_breadcrumb]');
}
add_filter('monawp_entry_breadcrumbs_html_filter', 'replace_mona_breadcrumbs_with_rankmath', 10, 1);
Or create your own function and use any shortcode or custom breadcrumbs.