Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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.png

    #1401476

    Hi 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,
    Nikko

    #1401659

    I`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?

    #1401679

    Hi,
    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,
    Mike

    #1401763

    Hi, 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.

    #1401767

    Hi,
    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,
    Mike

    #1401777

    It works! Thank you very much!

    #1401820

    Hi,

    Great, I’m glad that Mike could help you out. Please let us know if you should need any further help on the topic, or if we can close it.

    Best regards,
    Rikard

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.