-
AuthorPosts
-
March 16, 2023 at 6:29 pm #1401402
Hi, guys!
I need to use yoast seo breadcrambs. It possible to put
<?php
if ( function_exists(‘yoast_breadcrumb’) ) {
yoast_breadcrumb( ‘<p id=”breadcrumbs”>’,'</p>’ );
}
?>
for it.
Can I put this code via functions.php to not edit original theme files?
I’m using left sidebar for logo and menu (if it important).May be here?
https://i.postimg.cc/SjYNgsFQ/2023-03-16-202540.png
https://i.postimg.cc/fJ4WpNDc/2023-03-16-202646.pngMarch 17, 2023 at 4:25 am #1401476Hi mischael1,
Please try Ismael’s solution in this thread: https://kriesi.at/support/topic/yoast-breadcrumbs-integration-in-2022-enfold-v4-8-x/
Hope it helps.Best regards,
NikkoMarch 19, 2023 at 7:59 am #1401659I`ve tried to add code https://pastebin.com/2HHVQ9bs (from this topic) to functions.php of my child theme, but nothing happend.
As I understand this code replacing default breadcrambs (BC) with Yoast BC, but with logo-menu in left-sidebar style default BC not showing and thats why nothing changed.
May be possible to add little bit of code as I wrote in my first message of this topic?March 19, 2023 at 1:44 pm #1401679Hi,
Thank you for the link to your site, most of the posts I checked looked like they were created with the Advanced Layout Builder and not the default WordPress editor so the page HTML structure doesn’t match your screenshots on those posts. I did find the post in your screenshot.
For the ALB posts you can add the Yoast breadcrumbs by using their shortcode above the title.[wpseo_breadcrumb]
in a code block element.
For your posts created with the WordPress editor, try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:function add_yoast_breadcrumbs_shortcode_before_single_post_title() { ?> <script> (function($){ var wpseo_breadcrumb = '<span id="breadcrumbs"><?php echo do_shortcode("[wpseo_breadcrumb]"); ?></span>'; $('#top.single-post').each(function () { $(wpseo_breadcrumb).insertBefore('h1.post-title.entry-title'); }); })(jQuery); </script> <?php } add_action('wp_footer', 'add_yoast_breadcrumbs_shortcode_before_single_post_title');
Best regards,
MikeMarch 20, 2023 at 11:22 am #1401763Hi, Mike! Thank you for your attention.
With ALB no problem it works great with shortcode.Problem with classic editor. As I wrote I’m using general layout Logo And Main Menu at the left sidebar. This is importand as I understand, because when using general layout Logo And Main Menu at the Top Header your code works great. But I need to see breadcrambs before title with left sidebar general layout.
I made 2 screenshots (changing general layout).
general layout logo menu on top header https://i.postimg.cc/9RkFgjTr/for-breadcrambs.png — your code works perfectly, but i’m using another layout.
general layout logo menu left sidebar https://i.postimg.cc/bdGvDscb/for-breadcrambs-no.png — your code not work, but needed.Please, help.
March 20, 2023 at 11:50 am #1401767Hi,
I see that you are getting this error:Uncaught ReferenceError: jQuery is not defined
try this instead:function add_yoast_breadcrumbs_shortcode_before_single_post_titles() { ?> <script> window.addEventListener('DOMContentLoaded', function() { (function($){ var wpseo_breadcrumb = '<span id="breadcrumbs"><?php echo do_shortcode("[wpseo_breadcrumb]"); ?></span>'; $('#top.single-post').each(function () { $(wpseo_breadcrumb).insertBefore('h1.post-title.entry-title'); }); })(jQuery); }); </script> <?php } add_action('wp_footer', 'add_yoast_breadcrumbs_shortcode_before_single_post_titles');
If this doesn’t help please include an admin login in the Private Content area so we can be of more assistance.
Best regards,
MikeMarch 20, 2023 at 1:15 pm #1401777It works! Thank you very much!
March 20, 2023 at 7:09 pm #1401820 -
AuthorPosts
- You must be logged in to reply to this topic.