• Resolved webelaine

    (@wpgirl369)


    Is there a filter available to change the HTML element inside the breadcrumbs? I would like to change the last item in the breadcrumbs from a <span> to a <h1>.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    While Yoast does not have a filter to change the item you can target the last item using CSS.

    Unfortunately, we can’t offer support on custom code (needed to change (core) features of our plugin). Since we don’t want to take the risk that we break your website by suggesting incorrect or incomplete code, we cannot advise you on how to make such changes. Maybe someone watching these forums can assist you further, but if your topic is inactive for 7 days, we’ll mark it as resolved to keep the overview.

    You may also wish to review how to use CSS (if needed) using this guide: https://www.w3schools.com/css.

    Thank you for your understanding.

    Thread Starter webelaine

    (@wpgirl369)

    For anyone else who comes across this topic, I did find a way using a regular expression.

    <?php
    add_filter('wpseo_breadcrumb_single_link', 'filter_breadcrumbs_for_h1', 10, 2);
    function filter_breadcrumbs_for_h1($link_output, $link) {
    	$link_output = preg_replace("/<span\s(.+?)>(.+?)<\/span>/is", "<h1 $1>$2</h1>", $link_output);
    	return $link_output;
    }
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change breadcrumb element’ is closed to new replies.