Custom Breadcrumbs in SEO Title
-
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)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Custom Breadcrumbs in SEO Title’ is closed to new replies.