Skip to content

Instantly share code, notes, and snippets.

@louisesalas
Created June 2, 2021 07:06
Show Gist options
  • Save louisesalas/0bec73fdf47e26807dfbbdc8db9da3f2 to your computer and use it in GitHub Desktop.
Save louisesalas/0bec73fdf47e26807dfbbdc8db9da3f2 to your computer and use it in GitHub Desktop.
Remove <span> in Yoast breadcrumbs before the <li> tags
<?php
/**
* Filter the output of Yoast breadcrumbs to remove <span> tags added by the plugin
* @param $output
*
* @return mixed
*/
function louise93_yoast_breadcrumb_output( $output ){
$from = '<span>';
$to = '</span>';
$output = str_replace( $from, $to, $output );
return $output;
}
add_filter( 'wpseo_breadcrumb_output', 'louise93_yoast_breadcrumb_output' );
/**
* Shortcut function to output Yoast breadcrumbs
* wrapped in the appropriate markup
*/
function louise93_breadcrumbs() {
if ( function_exists('yoast_breadcrumb') ) {
yoast_breadcrumb('<ul>', '</ul>');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment