Archived topic
Adding Breadcrumbs to GP
28 replies · Started by James on February 1, 2018
Good morning Tom,
I have been reading through quite a few posts related to getting breadcrumbs on a GP site but it seems a little overwhelming as I do not know PHP and am fearful I will make a mistake.
It seems most references are made to the Yoast plugin which is what I use as well so that part is good.
I've seen some posts where the suggestion is to add some php code and others stating to add in the hooks section (I've most likely got the naming wrong apologies)
I've also seen comments like disable execution of php (I think that was it) and another stating to make sure execute PHP was checked.
Nonetheless what I would like to achieve is having breadcrumbs on my posts and pages (except home page) for a complete newbie who knows absolutely nothing about php code etc. what would you suggest as the easiest method for me to accomplish this?
I appreciate your feedback and support. Thanks as always.
Hi there,
Yoast SEO would be the best option.
You can add it in using similar code here: https://generatepress.com/forums/topic/yoast-breadcrumbs-styling/#post-467121
Let me know if you need more info :)
Hi Leo I think this has worked itself out I need to do a few edits and double check prior to marking resolved. Thanks. This has lead me to two more questions but they're not breadcrumb related so I will open a new thread on those topics:
Single Post Image Size
Meta Data
thanks.
James
No problem :)
Sounds good!
Leo it worked nicely thank you however it is also showing on all my pages and I'm hoping to only show the breadcrumbs on blog post pages is there something in the code I would need to add/change?
Thanks.
James
Try this:
<?php if ( function_exists('yoast_breadcrumb') && is_single() ) : ?>
<div class="grid-container yoast-breadcrumb">
<?php yoast_breadcrumb( '<p id="breadcrumbs">','</p>' ); ?>
</div>
<?php endif; ?>
This worked fantastically!!!
All pages including Home Page are no longer showing the breadcrumbs
HOWEVER
On my Blog main page they are still showing is there one more snippet I can add in that will remove it from the main blog page as well?
AND
I now have lost the breadcrumbs on the single blog posts themselves which is where I was hoping to have them appear?
JP
The code I had before makes them ONLY show on blog page.
Just edited so they should ONLY show on single posts.
Thanks Leo so the correct code to have the breadcrumbs only appear on single post pages is as you noted above and I'm copied below?
<?php if ( function_exists('yoast_breadcrumb') && is_single() ) : ?>
<?php endif; ?>
Yup the exact code here: https://generatepress.com/forums/topic/adding-breadcrumbs-to-gp/#post-489535
Hi Leo
I read this post with interest. Is there a code to just leave it out of the front page only?
Thanks
Try this:
<?php if ( function_exists('yoast_breadcrumb') && ! is_front_page() ) : ?>
<div class="grid-container yoast-breadcrumb">
<?php yoast_breadcrumb( '<p id="breadcrumbs">','</p>' ); ?>
</div>
<?php endif; ?>
More info here if you are interested: https://docs.generatepress.com/article/using-hooks-conditional-tags/
Worked like a charm! Thank you very much :-)
No problem :)
Leo,
Just a quick recap on how and where do I add this code you wrote?