[Resolved] Issue Implementing Yoast Breadcrumbs Using Hook Element

Home Forums Support [Resolved] Issue Implementing Yoast Breadcrumbs Using Hook Element

Home Forums Support Issue Implementing Yoast Breadcrumbs Using Hook Element

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1380740
    Andres

    Hello,

    I’ve run into an issue implementing Yoast Breadcrumbs (YB) using a Hook Element as explained in this doc: https://docs.generatepress.com/article/adding-breadcrumbs/

    Steps Taken:

    Steps:

    1. Create a Hook Element in Generate Press
    2. Set hook to: after_entry_title
    3. Set display rules to: Entire site
    4. Enabled the option Execute Short Codes
    5. Pasted the code below provided by Yoast in the code field
    6. Updated the hook element
    7. Enabled Yoast Breadcrumbs

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

    8. Went to a post to verify if working. This appeared instead of breadcrumbs: ‘,’
    ‘ ); } ?>

    Notes: I noticed that when creating this hook element, that in the Execute PHP option, it showed: Unable to execute PHP as DISALLOW_FILE_EDIT is defined. I ignored this as I was using the short code option.

    In looking for a solution, I found this support ticket: GP Support Topic: https://generatepress.com/forums/topic/install-yoast-breadcrumbs/

    It’s mentioned that directive “define(‘DISALLOW_FILE_EDIT’, false);” in wp-config.php might be the cause. I set it to “false”, the Theme Editor was available in Appearance, and YB still
    l did not work. I removed the entire directive and YB worked

    I noticed that this directive is not available by default in the wp-config.php file. I included it when implementing a security strategy.

    In contacting Yoast, they replied: “You mentioned that the Yoast breadcrumbs don’t appear when you set DISALLOW_FILE_EDIT to false. This is strange because the feature doesn’t require it.”

    I thought I’d contact you guys to see what resolution you would recommend to be able to use the hook element and have the file editor disabled.

    I’ve left YB and the hook element enabled, as well as code in wp-config.php in place and set to “true” so you can see the issue (see the included URL, please).

    Thank you and have a good day.

    Cheers!

    Andrés

    #1380817
    Leo
    Staff
    Customer Support

    Hi there,

    Have you tried the shortcode option instructed in the doc article?

    You can find the shortcode on this page under the Implement breadcrumbs on pages using a shortcode section:
    https://yoast.com/help/implement-wordpress-seo-breadcrumbs/

    #1380865
    Andres

    Hi Leo,

    Boy, do I feel like and idiot. I thought the code they provided was the code to insert in the hook element. That was a waste of three hours! Sorry for the bother and wasting your time. Too many novices, too little time. I input the shortcode and it works. Thank you.

    On another note, where can I find the filter to remove the current post from the breadcrumbs so that it only shows: Home > Category Title?

    Also, is it possible to change the name of the category in the breadcrumbs and not change the title of the category, which is the H1? It’s just too long, and for mobile, it’s ridiculously long. They want you to use descriptive titles for user experience and SEO, but then they look horrible in breadcrumbs.

    Current Breadcrumb: Home > Costa Rica Wedding Photography > Post Name

    Change to: Home > Gallery

    From what I understand, GP adds information to the title of posts when using the Title Field that’s beneficial for SEO. I know I can change the category title to “Gallery”, then have it not show on the category page, and then create an H1 on the page itself, but this is not the best solution from what I gather.

    Thank you very much, Leo, and have a great day!

    Andrés

    #1381124
    Leo
    Staff
    Customer Support

    On another note, where can I find the filter to remove the current post from the breadcrumbs so that it only shows: Home > Category Title?

    Also, is it possible to change the name of the category in the breadcrumbs and not change the title of the category, which is the H1? It’s just too long, and for mobile, it’s ridiculously long. They want you to use descriptive titles for user experience and SEO, but then they look horrible in breadcrumbs.

    This is something you will need to check with Yoast’s support.

    I’ll mark this topic as resolved for now 🙂

    #1381224
    Andres

    Hello Leo,

    Here’s how to remove the post title name from Yoast Breadcrumbs (insert in functions.php in child them or other method)

    add_filter('wpseo_breadcrumb_single_link', 'remove_breadcrumb_title' );
    function remove_breadcrumb_title( $link_output) {
    	if(strpos( $link_output, 'breadcrumb_last' ) !== false ) {
    		$link_output = '';
    	}
       	return $link_output;
    }

    Here’s how to set the name of the category and post name that appears in the Yoast Breadcrumbs, allowing one have a descriptive post and category titles and truncate the title that appears in breadcrumbs.

    For categories:

    Got to: Posts > Categories > Edit (choose category to edit > Yoast SEO (at bottom) > Advanced > Breadcrumbs Title

    For Posts:

    Got to: Posts / > Edit (choose post to edit > Yoast SEO (at bottom) > Advanced > Breadcrumbs Title (and insert desired category or post name in corresponding field).

    Hope this helps someone.

    Thanks for all help Leo!

    Have a good night.

    Andrés

    #1381342
    Leo
    Staff
    Customer Support

    Thanks for sharing!

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