Breadcrumbs help users and search engines understand the structure of a website. If you use GeoDirectory with Yoast SEO or Rank Math, you may notice that the default breadcrumbs don’t show the right location details. This guide will help you fix that so your website looks better and is easier to use.
Why change Breadcrumbs for GeoDirectory?
GeoDirectory helps you create a directory with locations, categories, business listings, events, and custom post types. However, many SEO plugins like Yoast or Rank Math don’t automatically recognize these special pages, leading to incorrect or incomplete breadcrumbs. Fixing them will help:
- Show the correct path for location-based listings
- Ensure event pages and listings are structured correctly
- Improve your SEO and ranking on Google
- Help users return to parent locations and categories easily
- Enhance internal linking and site navigation
Structure of GeoDirectory Breadcrumbs
GeoDirectory generates different types of content, such as:
- Single Business Listings (
gd_place
) – Individual business pages - Categories (
gd_placecategory
) – Listing groupings like “Restaurants” or “Hotels” - Cities (
gd_city
) – Location-based taxonomies - Events (
gd_event
) – Special event pages - Custom Post Types – User-defined directory sections
To modify breadcrumbs for all these cases, we need custom code.
How to Fix Yoast SEO Breadcrumbs for GeoDirectory
1. Enable Yoast Breadcrumbs
Before modifying breadcrumbs, enable them:
- Go to SEO > Search Appearance > Breadcrumbs
- Toggle Enable Breadcrumbs to “Enabled”
- Save changes
2. Modify Breadcrumbs for GeoDirectory Listings
Since GeoDirectory dynamically generates pages, we need a custom function to insert cities and categories into breadcrumbs. Add this to your theme’s functions.php
file:
add_filter('wpseo_breadcrumb_links', 'custom_yoast_breadcrumbs_for_geodirectory'); function custom_yoast_breadcrumbs_for_geodirectory($links) { if (is_singular('gd_place') || is_singular('gd_event')) { $post_id = get_the_ID(); $city = get_the_terms($post_id, 'gd_city'); $category = get_the_terms($post_id, 'gd_placecategory'); if ($city && !is_wp_error($city)) { array_splice($links, 1, 0, array(array( 'text' => $city[0]->name, 'url' => get_term_link($city[0]), ))); } if ($category && !is_wp_error($category)) { array_splice($links, 2, 0, array(array( 'text' => $category[0]->name, 'url' => get_term_link($category[0]), ))); } } return $links; }
Code Explanation
- Handles multiple GeoDirectory types: Works for business listings and events.
- Adds City to Breadcrumbs: Retrieves the listing’s city and places it after “Home.”
- Adds Category to Breadcrumbs: Retrieves and inserts the business category after the city.
- Ensures correct hierarchy: Maintains breadcrumb structure for SEO.
3. Verify and Test Your Changes
Visit a GeoDirectory listing or event page and check the breadcrumbs to confirm the city and category appear correctly.
How to Fix Rank Math Breadcrumbs for GeoDirectory
1. Enable Rank Math Breadcrumbs
- Go to Rank Math > General Settings > Breadcrumbs
- Toggle Enable Breadcrumbs Functionality to “Enabled”
- Save changes
2. Modify Breadcrumbs for GeoDirectory
For Rank Math, use this code in your functions.php
file:
add_filter('rank_math/frontend/breadcrumb/items', function($crumbs) { if (is_singular('gd_place') || is_singular('gd_event')) { $post_id = get_the_ID(); $city = get_the_terms($post_id, 'gd_city'); $category = get_the_terms($post_id, 'gd_placecategory'); if ($city && !is_wp_error($city)) { array_splice($crumbs, 1, 0, array([ 'name' => $city[0]->name, 'url' => get_term_link($city[0]), ])); } if ($category && !is_wp_error($category)) { array_splice($crumbs, 2, 0, array([ 'name' => $category[0]->name, 'url' => get_term_link($category[0]), ])); } } return $crumbs; });
3. Test and Confirm Changes
Check your directory pages and ensure breadcrumbs are correctly structured with locations and categories.
Need Help Customizing Breadcrumbs for GeoDirectory?
Struggling to integrate Yoast or Rank Math breadcrumbs with GeoDirectory? Get expert guidance to ensure seamless navigation and improved SEO.
Frequently Asked Questions (FAQs)
1. How do breadcrumbs improve SEO?
Breadcrumbs create a structured path that helps search engines index your site better. They improve navigation and increase click-through rates.
2. Why do my breadcrumbs only show “Home” and the listing name?
GeoDirectory pages are dynamic and require manual breadcrumb adjustments using custom code as shown above.
3. Can I modify breadcrumbs for other post types?
Yes! Extend the code above to include custom post types such as gd_event
or any other taxonomy relevant to your directory.
4. Will these changes affect my overall site breadcrumbs?
No, these modifications apply only to GeoDirectory pages. Other parts of your site using default Yoast or Rank Math breadcrumbs will remain unchanged.
5. Do I need to update the code with every plugin update?
Not necessarily, but you should check if any major updates affect the breadcrumb functionality.
6. What if I want to display parent categories as well?
You can modify the code to include parent categories by retrieving the hierarchical structure from gd_placecategory
.
7. What if I want a custom separator for breadcrumbs?
Both Yoast and Rank Math allow you to change the breadcrumb separator in their settings panel.
8. How can I test if Google recognizes my breadcrumbs correctly?
Use Google Search Console’s Rich Results Test to verify how Google sees your breadcrumbs.
9. Can I add breadcrumbs to a widget area?
Yes, use (Yoast) or
<?php if (function_exists('rank_math_the_breadcrumbs')) rank_math_the_breadcrumbs(); ?>
for Rank Math.
10. Where can I get help if I need advanced customization?
Join GeoDirectory’s forums or hire a developer specializing in WordPress and SEO.
Conclusion
Fixing breadcrumbs in Yoast or Rank Math for GeoDirectory is crucial for better SEO and user experience. With the right code, you ensure that all location-based pages display their hierarchy correctly, improving site navigation and search rankings.
Need Custom Features for GeoDirectory?
Customize the GeoDirectory plugin to fit your unique business needs. Get a FREE ESTIMATE and expert help for tailored layouts, custom fields, and advanced functionality.