Custom Breadcrumbs in SEO Title
-
Hello!
I’m trying to create a custom breadcrumb trail to add to the Yoast SEO title and meta description of my WooCommerce product categories. I’ve customized the /woocommerce/templates/global/breadcrumb.php file in my theme folder and have the following in my functions.php file. However, the code prints the breadcrumb list several times and outside the <title></title> tags.
Please advise as to the best way to fix this, thanks!!
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 }); 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 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Custom Breadcrumbs in SEO Title’ is closed to new replies.