• I want to show breadcrumbs in my post.

    I have taken the following steps but could not be successful.

    Added this PHP Code:

    <?php
    if ( function_exists(‘yoast_breadcrumb’) ) {
    yoast_breadcrumb( ‘<div class=”yoast-breadcrumb container” style=”margin-bottom: 20px”>
    <div id=”breadcrumbs” class=”col-md-12″ style=”background: white;padding: 15px;”>’,'</div></div>’ );
    }
    ?>

    Add CSS:
    Breadcrumb NavXT Plugin installed.

    Necessary YoastSEO settings also done.

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Hi there,

    you can add this PHP Snippet to your site:

    add_action( 'generate_before_content', function(){
        if ( function_exists(‘yoast_breadcrumb’) ) {
            yoast_breadcrumb( ‘<div class=”yoast-breadcrumb container” style=”margin-bottom: 20px”>
            <div id=”breadcrumbs” class=”col-md-12″ style=”background: white;padding: 15px;”>’,'</div></div>’ );
        }
    });

    How to add PHP: https://docs.generatepress.com/article/adding-php/

    Thread Starter aish547

    (@aish547)

    Should I remove all other php code, css and plugin?

    Thread Starter aish547

    (@aish547)

    Also, I got this reply for your code:

    The code snippet you are trying to save produced a fatal error on line 3:

    syntax error, unexpected ‘class’ (T_CLASS), expecting ‘)’

    Yes, remove the over codes, and try this:

    add_action( 'generate_before_content', function() {
        if ( function_exists('yoast_breadcrumb') ) {
            yoast_breadcrumb( '<div class="grid-container grid-parent"><p id="breadcrumbs">','</p></div>' );
        }
    } );
    Thread Starter aish547

    (@aish547)

    Hey!

    I need to show breadcrumbs only in single posts. It shows in the blog listing too.

    Change the code to:

    add_action( 'generate_before_content', function() {
        if ( function_exists('yoast_breadcrumb') && is_single() ) {
            yoast_breadcrumb( '<div class="grid-container grid-parent"><p id="breadcrumbs">','</p></div>' );
        }
    } );
    Thread Starter aish547

    (@aish547)

    It works. Thanks @david!

    Just a few corrections:

    1. Don’t want to show the primary category in the breadcrumb.
    2. The name of the post shall be in green colour.

    1. That is controlled by Yoast:

    https://yoast.com/features/breadcrumb-controls/

    2. you can add your own CSS style for that, the last item of the breadcrumb has the breadcrumb_last class – so you can add this CSS:

    .breadcrumb_last {
        color: #0f0;
    }
    Thread Starter aish547

    (@aish547)

    Thanks!

    Thread Starter aish547

    (@aish547)

    Here is an issue:

    For Example: On this page: https://lawbhoomi.com/law-college-search/vrindavan-law-college-mathura-up/

    Instead of Law College Search: Search All Law Colleges in India, I want it should show “All Blogs” and

    for

    “LL.B.”: [space].

    I tried:
    .single.grid-container.grid-parent >p >span >span a { content = “All Blogs”;}
    .single.grid-container.grid-parent >p >span >span >span a { content = ” “;}

    Leo

    (@leohsiang)

    That’s not something the theme can control – I would recommend checking with the breadcrumb plugin author.

    Thanks for your understanding.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Breadcrumbs not shown in posts’ is closed to new replies.