Archived topic
How to create Hook for Yoast SEO breadcrumbs
8 replies · Started by Zohaib on October 21, 2017
Hi Tom,
I have used Yoast Seo script to generate breadcrumbs by adding the code to the singlepage.php file. However, I do not want them to appear on the homepage as it is showing right now. Here is the link to the website https://www.superbeyebrows.co.uk. I have noticed someone else mentioned that we can use manual hooks to add the breadcrumb script but I do not know to add this. Please, can you help me with this?
Hi there,
Yup you can use GP hook:
https://docs.generatepress.com/article/hooks-overview/
http://demo.generatepress.com/hook-locations/
With conditional tag like this to exclude home page:
<?php if ( ! is_front_page() ) : ?>
code here
<?php endif; ?>
And make sure execute PHP is checked.
Hi Leo,
Thanks for getting back to me.
I have implemented below code and it is working fine. However, on the blog page, breadcrumbs appear with every single post. I want the breadcrumb to appear only once on the top. Can you help me resolve this issue.
Thanks
Zo
Here is the code:
<?php if ( ! is_front_page() ) : ?>
<?php if ( function_exists('yoast_breadcrumb') ) { ?>
<div class="grid-container grid-parent">
<div class="page-header">
<?php yoast_breadcrumb('<p id="breadcrumbs">','</p>'); ?>
</div>
</div>
<?php } ?>
<?php endif; ?>
Where are you adding the code?
I have implemented the code on below header hook.
Thanks
In after header hook?
Any reason you added the page header class div?
Could you please check and help me to implement breadcrumbs correctly?
Currently I only see the structure of Breadcrumbs on the left border.
Thank you
Karsten
Hi there,
we can cover this on your own topic. Thanks