Site logo

[Resolved] Breadcrumbs + Rankmath

Home Forums Support [Resolved] Breadcrumbs + Rankmath

Home Forums Support Breadcrumbs + Rankmath

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #2443654
    Stephan Bloemers

    Hello,
    i have a problem with the breadcrumbs and rankmath.

    I use the Code Snippets plugin to insert the breadcrumbs. For this I use the following code:

    add_action( 'generate_after_content', function() {
        if ( function_exists('rank_math_the_breadcrumbs') ) {
            rank_math_the_breadcrumbs( '<div class="grid-container grid-parent"><p id="breadcrumbs">','</p></div>' );
        }
    } );

    Unfortunately then appears on page 2 of my blog:
    Page 2
    Page 3 then shows:
    side
    etc.

    This is not displayed within my contribution (which is also correct), only on the overview

    overview

    #2443685
    Leo
    Staff
    Customer Support

    Hi there,

    Have you considered creating an Element with a shortcode to add the breadcrumbs?

    That way you can use the display rules to control where it shows and doesn’t show.

    Take a look at the instruction here:
    https://docs.generatepress.com/article/adding-breadcrumbs/

    Let me know if this helps 🙂

    #2443707
    Stephan Bloemers

    Thank you for the tip, that would of course work, but for certain reasons it is not possible for me in this specific case.

    At first I thought there was a problem with rankmath, so I contacted them. I was advised the following:
    You can get in touch with them and ask them to only restrict the preview for the content inside the entry-content div

    #2443727
    Leo
    Staff
    Customer Support

    So you just want to remove it from page 2 and so on?

    If so you would need to include a conditional tag:
    https://codex.wordpress.org/Conditional_Tags#A_Paged_Page

    #2445081
    Stephan Bloemers

    I may not seem to be expressing myself clearly. May be due to google translator.

    At https://docs.generatepress.com/article/adding-breadcrumbs/ you specify how to insert breadcrumbs using a function. However, this will result in an error if the breadcrumbs are not inserted “after_header” but “after_content”.

    Everything is fine on the home page. If I continue to page 2 in the blog, the error shown in the picture appears.

    #2445636
    Leo
    Staff
    Customer Support

    I don’t see any breadcrumbs on the home page (first page) – is that what you wanted?

    Breadcrumbs are normally only added in single posts.

    Let me know 🙂

    #2445703
    Stephan Bloemers

    You have to go to the second page

    #2445730
    Leo
    Staff
    Customer Support

    There is some miscommunications here for sure.

    Let me rephrase the question: What is the expected result here?

    Where would you like the breadcrumbs to display? Only on single posts?

    #2445739
    Stephan Bloemers

    Yes, the breadcrumbs should only be within the individual posts.
    However, the page number “2” is also displayed on the “overview page”.

    #2445745
    Leo
    Staff
    Customer Support

    Try this snippet instead:

    add_action( 'generate_after_content', function() {
        if ( function_exists('rank_math_the_breadcrumbs') && is_single() ) {
            rank_math_the_breadcrumbs( '<div class="grid-container grid-parent"><p id="breadcrumbs">','</p></div>' );
        }
    } );
    #2445758
    Stephan Bloemers

    Thank you very much, that solves the problem.
    And also thank you for your patience

    #2447299
    Leo
    Staff
    Customer Support

    No problem 🙂

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