- This topic has 11 replies, 2 voices, and was last updated 2 years, 9 months ago by
Leo.
-
AuthorPosts
-
November 30, 2022 at 3:53 pm #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
November 30, 2022 at 4:12 pm #2443685Leo
StaffCustomer SupportHi 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 🙂
November 30, 2022 at 4:33 pm #2443707Stephan 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 divNovember 30, 2022 at 5:05 pm #2443727Leo
StaffCustomer SupportSo 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_PageDecember 1, 2022 at 10:04 am #2445081Stephan 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.
December 1, 2022 at 2:18 pm #2445636Leo
StaffCustomer SupportI 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 🙂
December 1, 2022 at 2:57 pm #2445703Stephan Bloemers
You have to go to the second page
December 1, 2022 at 3:28 pm #2445730Leo
StaffCustomer SupportThere 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?
December 1, 2022 at 3:33 pm #2445739Stephan Bloemers
Yes, the breadcrumbs should only be within the individual posts.
However, the page number “2” is also displayed on the “overview page”.December 1, 2022 at 3:37 pm #2445745Leo
StaffCustomer SupportTry 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>' ); } } );
December 1, 2022 at 3:47 pm #2445758Stephan Bloemers
Thank you very much, that solves the problem.
And also thank you for your patienceDecember 2, 2022 at 2:51 pm #2447299Leo
StaffCustomer SupportNo problem 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.