Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1102451

    cocoarepublic
    Participant

    Hi, I’m attempting to input YoastSEO’s breadcrumbs code:

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

    ..to somewhere under my page title header, but I don’t know whether (or where) to add to functions.php or single.php as instructed by the video.

    #1102457

    cocoarepublic
    Participant
    This reply has been marked as private.
    #1102893

    Prasant Rai
    Moderator

    Hello There,

    Thanks for writing in!

    Because this requires a template change, I’d advise that you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released.

    Then place following code in child theme function.php file:

    if ( ! function_exists( 'x_breadcrumbs' ) ) :
      function x_breadcrumbs() {
    
        if ( x_get_option( 'x_breadcrumb_display', 1 ) && function_exists('yoast_breadcrumb') ) {
              yoast_breadcrumb('<p id="breadcrumbs">','</p>');
        } 
    
      }
    endif;

    Let us know how it goes.

    Thanks.

    #1145932

    jlswilton
    Participant

    Hi, adding on here. I just did this, but nothing changed. I still have X breadcrumbs on my layout pages and nothing showing on my no container-header-footer pages. Any other suggestions? I’ve searched around the forum quite a bit and haven’t found an answer that works. In my case, I don’t care if it’s X breadcrumbs or Yoast, I just need something that will show up on the pages I want (and not show up on some others). Suggestions welcome!

    #1146150

    Lely
    Moderator

    Hi There,

    Please try this code instead:

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

    Previous code check if Breadcrumbs is set to ON in the customizer.

    Hope this helps.

    #1148192

    jlswilton
    Participant

    It still only shows on pages that use a layout, not the no container pages.

    #1148766

    Rad
    Moderator

    Hi there,

    Yes, because they are blank templates. They have no landmark, breadcrumb, titles, comments, sidebars, and more, hence, blank templates. And you’ll have to compose or build static content on them.

    Thanks!

    #1148895

    jlswilton
    Participant

    Yes, I understand that, but it is possible to do this via CSS. I’m not really sure what is unclear about my request.

    #1149240

    Rad
    Moderator

    Hi there,

    It’s not doable through CSS, what you’ll need is custom coding. Please add this code to your child theme’s functions.php

    add_action('x_before_view__content-the-content', 'page_breadcrumbs');
    function page_breadcrumbs () { 
    
    if ( is_page_template( array(
    
    'template-blank-1.php',
    'template-blank-2.php',
    'template-blank-3.php',
    'template-blank-4.php',
    'template-blank-5.php',
    'template-blank-6.php',
    'template-blank-7.php',
    'template-blank-8.php',
    
    ) ) && function_exists('yoast_breadcrumb') ) echo '<div class="x-container max width">'.yoast_breadcrumb('<p id="breadcrumbs">','</p>').'</div>';
    
    }

    Hope this helps.