Site logo

Archived topic

Adding breadcrumbs without Yoast

3 replies · Started by Sneaky on May 25, 2022

Viewing posts 1–4 of 4

First, adding a breadcrumbs option in the customiser makes more sense than suggesting that you use another plugin, especially Yoast.

Before I go off and look for some other alternatives, are there any other known ways to get this to work without a third-party plugin?

Hi there,

for a really basic breadcrumb you can:

1. Create a new Hook Element
1.1 In the hook text area add:

<?php
function get_breadcrumb() {
    echo '<a href="'.home_url().'" rel="nofollow">Home</a>';
    if ( is_category() || is_single() ){
        echo "  »  ";
        the_category (' • ');
        if ( is_single() ) {
            echo " » ";
            the_title();
        }
    } elseif ( is_page() ) {
        echo " » ";
        echo the_title();
    }
}
get_breadcrumb();
?>

1.2 Set the Hook to where you want it to appear eg. generate_before_main_content
See here for other general hooks:
https://docs.generatepress.com/article/hooks-visual-guide/

1.3 Check Execute PHP
1.4 Set the Display Rules to where you want it displayed
eg. Posts > All Posts, Pages > All Pages, Category Archives > All Categories.

Alternatively use a dedicated plugin - theres a few to choose from:

https://wordpress.org/plugins/breadcrumb-navxt/
https://wordpress.org/plugins/flexy-breadcrumb/
https://wordpress.org/plugins/breadcrumb/

The advantage of the plugin is they will handle custom permalink structures, custom taxonomies/post types and other advanced stuff - some including adding schema

Thanks, I have gone with a plugin. Maybe you can look at adding this in a new release soon. Most other similar themes similar to yours (functions wide) have this as standard.

Glad to hear you have something that works for you. And thanks for the suggestion!

This archived topic is closed to new replies.