• Resolved sweettea2

    (@sweettea2)


    Hello! I’m trying to print the breadcrumbs for WooCommerce product category pages in the SEO title and meta description through Yoast. I’ve looked at the variable page (https://yoast.com/help/list-available-snippet-variables-yoast-seo/), but have not been able to get something working that does what I need.

    Would there be a way to print breadcrumbs as a custom Yoast variable? Here is what I have…please advise. Thanks so much!

    add_filter( 'woocommerce_breadcrumb_defaults', 'diy_woocommerce_breadcrumbs' );
    function diy_woocommerce_breadcrumbs() {
        return array(
                'delimiter'   => ' ',
                'wrap_before' => '',
                'wrap_after'  => '',
                'before'      => '',
                'after'       => '',
            );
    }
    
    add_filter( 'woocommerce_breadcrumb_defaults',function( $defaults ) {
        unset($defaults['home']);//removes home link.
        return $defaults;//returns rest of links
    });
    
    remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb' );
    
    function get_diy_catlist() {
        return woocommerce_breadcrumb();
    }
    
    // define the action for register yoast_variable replacments
    function register_custom_diyyoast_variables() {
        wpseo_register_var_replacement( '%%diycatlist%%', 'get_diy_catlist', 'advanced', 'some help text' );
    }
    
    // Add action
    add_action('wpseo_register_extra_replacements', 'register_custom_diyyoast_variables');
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Michael Ti?a

    (@mikes41720)

    Hello @sweettea2

    Could you please clarify a bit more on what you’re trying to do? When you mean ‘print breadcrumbs’, do you mean you want to use the Yoast snippet variables as the output for your WooCommerce breadcrumbs?

    Thread Starter sweettea2

    (@sweettea2)

    Yes, thanks for your response! I ultimately want to be able to have the list of breadcrumbs in the Yoast SEO meta title and description of the WooCommerce product category and product pages.

    So, for example, the highest product category page would have a title of “FORD title”, the next level would be “FORD FOCUS title”, the next level would be “FORD FOCUS 2001 title” and so on.

    I don’t really mind how this is achieved as long as it works. Hope this clarifies things!

    Plugin Support Md Mazedul Islam Khan

    (@mazedulislamkhan)

    Thanks for your clarification. As much as we hate to say it, your question goes beyond the technical expertise of me and my colleagues on the Yoast support team. This means we can’t give you a solid answer to your question.

    But we don’t want to leave you empty-handed either, that’s why we’ve created our developer portal at developer.yoast.com. This has proven to be useful to many developers in the past, and hopefully will serve you well too.

    Sorry we can’t be of more help here.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Breadcrumbs in SEO Title’ is closed to new replies.