Breadcrumb

  • Don’t Work
    add_action( ‘generate_before_main_content’, function() {
    if ( function_exists( ‘yoast_breadcrumb’ ) ) {
    yoast_breadcrumb( ‘<div class=”breadcrumbs”>’, ‘</div>’ );
    }
    } );

    .breadcrumbs {
    font-size: 14px;
    margin-bottom: 15px;
    color: #777;
    }

    .breadcrumbs a {
    color: #0073aa;
    text-decoration: none;
    }

    .breadcrumbs a:hover {
    text-decoration: underline;
    }

    Can you send me the correct code for breadcrumb?

  • Hi there,

    The code you posted has curly (smart) quotes instead of straight quotes — for example instead of '. This happens when copying code from sources that auto-format punctuation. PHP won’t recognize curly quotes, so the snippet either won’t work or will throw an error.

    Here’s a corrected version that also excludes the homepage so you don’t get “Home” showing up there:

    add_action( 'generate_before_main_content', function() {
        if ( function_exists( 'yoast_breadcrumb' ) && ! is_front_page() ) {
            yoast_breadcrumb( '<div class="breadcrumbs">', '</div>' );
        }
    } );

    Make sure when you paste this that your code editor or snippet plugin doesn’t convert the quotes back to curly ones.

    Your CSS should be good to go!

  • Could you please guide me on how to insert the PHP and CSS?
    I use a snippets plugin, but it’s not working yet.

  • Good to know!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.