Archived topic
How to add breadcrumb to every page with php code
9 replies · Started by amiee on March 2, 2021
Hi, there
Sorry for disturbing.
May I know how to add breadcrumb to every page with php code, or breadcrumb can be showed on every page without code?
Looking forward to your reply.
Thanks and regards
Hi amiee,
You can check our brief documentation on how to add Breadcrumbs here:
https://docs.generatepress.com/article/adding-breadcrumbs/
Thanks for your reply soon.
But I don't know add the code SEO given to which place, need to use plugin, or in theme editor directly, which file?
would you like to let me know?
The code"<?php
如果(function_exists('yoast_breadcrumb')){
yoast_breadcrumb('<p id =“ breadcrumbs”>','</ p>');
}
?>"
Thanks and regards
And I added to the end of header Theme Header php, now the post time and breadcrumb appeared on the same line? Why?
So how to do?
Thanks and regards
<?php
if ( function_exists('yoast_breadcrumb') ) {
yoast_breadcrumb( '<p id="breadcrumbs">','</p>' );
}
?>
The code is above.
Looking forward to your reply.
Thanks and regards
Here's our recommended way of adding PHP snippets.
https://docs.generatepress.com/article/adding-php/
Avoiding the parent theme's functions.php. If you prefer using a functions.php file, you must create a child theme.
I added the code“
add_action( 'generate_after_header', function() {
if ( function_exists('yoast_breadcrumb') ) {
yoast_breadcrumb( '
' );
}
} );
”
to the snippets plugin and Worked it out.
But a little trouble, breadcrumb showed on the front page though excluded the fornt page.
Thanks and Regards
Regards
Hi there,
change the snippet to:
add_action( 'generate_after_header', function() {
if ( ! is_front_page() && function_exists('yoast_breadcrumb') ) {
yoast_breadcrumb( '<div class="grid-container grid-parent"><p id="breadcrumbs">','</p></div>' );
}
} );
Hi, there
Everything is ok after I changed the code according to your help.
Thank you so much.
Regards
Glad we could be of help.