Yoast SEO breadcrumbs

Hi,

Could you please check this out and give your advice:

Cheers,
Ehsan

Dear Ehsan,

Try to insert the following code in the header.php file. Put it at the most bottom line.


<?php 
if ( !is_front_page() && function_exists('yoast_breadcrumb') ){
	yoast_breadcrumb('<p id="breadcrumbs">','</p>');
}
?>

You should pass it the child theme. Otherwise the code addition will be lost as the theme gets updated in the future.

Regards,
Kharis

Thank you dear Kharis,

I’m new to use child theme, could you please learn how can we echo parent PHP file in child them?

Thank you in advance,
Ehsan

Dear Ehsan,

Please follow the following resources:

Regards,
Kharis

Hello :slight_smile:

Thank you for your help, it almost works for me !

I don’t know why the breadcrumb appears only in Elementor pages and posts. Do you have an idea how I can appear the breadcrumb in all types of pages (especially in Gutenberg) ?

Thank a lot per advance for your help :slight_smile:

Alexa

Hi Alexa,

Perhaps your pages that don’t show breadcrumb has a special template.

  • Which template do you enable?
  • Do you use special header?

Regards,
Kharis
aThemes Support

Hi Kharis !

Thanks a lot for your help. I found a little solution (not the better one). The breadcrumb appears only in following pages

  • posts
  • elementor template
  • full width template …

It means, the bradcrumb appears only with wordpress template by default. But not with sydney template. Do you already have this issue ?

Thanks again, have a beautiful day,

Alexa

Hi Alexa,

Can you share the final code added you have added in the theme’s file, so I can check and make a little correction with it?

Regards,
Kharis
aThemes Support

Yes sure !

Here :

<?php if ( function_exists('yoast_breadcrumb') ) { yoast_breadcrumb( '

','

' ); } ?>

Hi,

Thank you for sharing the code. Please try replacing it to:

    add_action('sydney_after_hero', 'sydney_child_add_breadcrumb');
    function sydney_child_add_breadcrumb() {

      if function_exists('yoast_breadcrumb') ){
      	yoast_breadcrumb('<p id="breadcrumbs">','</p>');
      }

    }

Regards,
Kharis
aThemes Support

Thanks to help me !

With this code, the code appears at the end of the header.

Did I do something wrong ?

Hi,

Thank you for getting back.

Can you share the entire code in your child theme’s functions to https://gist.github.com/ and link it here? So I can replicate and correct it whenever possible.

Regards,
Kharis
aThemes Support

Yes sure !

The link : https://github.com/WebViaLexa/Yoast-breadcrumbs-with-Sydney-Pro/blob/main/header.php

Thank you for your help :slight_smile:

Hi,

Thank you for sharing.

The file to edit was incorrect. The snippet should have been inserted to the functions.php file. And no need to put PHP closing tag (?>) at the bottom line. Esure it is PHP error free.

Regards,
Kharis
aThemes Support

I chose header.php instead functions.php because it didn’t work with functions.php, see what happened when I put the code in functions.php

Thanks again for your time !

And see what happened if I remove the <?php in functions.php :

Hi,

You don’t need only on <?php on line: 9.

Because it illegal according to PHP coding standard.

Adding, here is the page, where you can learn more about PHP coding.

Regards,
Kharis
aThemes Support

Yes I tried too :slight_smile:

But it appears in wrong way, not with the breadscrumb

The only way to be sure it works, it’s if

  • I put the php code at the end of header.php
  • I choose the template “fullwidth” or wordpress template, not with the sydney template (like “no header image - wide” for example).

If you have other solution to propose me, I take ! Otherwise, it’s maybe a problem with my host or domain and maybe it won’t be the same issue with other project :wink:
I will see in real environment too :wink:

Hi,

I am sending you a private message requesting direct access to your website’s admin area. If you want, I’d like to fix the problem directly from there.

Regards,
Kharis
aThemes Support