How to add a class to the a tag in Yoast SEO breadcrumbs

0 votes

I am using Yoast Wordpress plugin and the breadcrumb function that it provides. It works great, but I want to modify the default structure and to add an additional class.

So instead of:

<a href="http://www.example.com" rel="v:url" property="v:title">Home</a>

I want to make it:

<a href="http://www.example.com" class="my-class" rel="v:url" property="v:title">Home</a>
Feb 21, 2022 in Others by Kichu
• 19,050 points
1,510 views

1 answer to this question.

0 votes
add_filter( 'wpseo_breadcrumb_single_link', 'ss_breadcrumb_single_link', 10, 2 );
function ss_breadcrumb_single_link( $link_output, $link ) {
$element = '';
$element = esc_attr( apply_filters( 'wpseo_breadcrumb_single_link_wrapper', $element ) );
$link_output =  $element;

if ( isset( $link['url'] ) ) {
    $link_output .= '<a rel="nofollow" href="' . 

 esc_url( $link['url'] ) . '" rel="v:url" property="v:title" class="my-class">' . 

 esc_html( $link['text'] ) . '</a>';
 }
 return $link_output;
}


this is a function.php code in this you can add the custom class to breadcrumbs 
answered Feb 22, 2022 by narikkadan
• 63,720 points

Related Questions In Others

0 votes
1 answer

How to add meta keyword in wordpress using yoast seo plugin.?

if you dont want to use code ...READ MORE

answered Feb 12, 2022 in Others by narikkadan
• 63,720 points
965 views
0 votes
1 answer

How to add a border to a widget in Flutter?

Hi@akhtar, You need to add the TextField as a child to a Container that has ...READ MORE

answered Jul 24, 2020 in Others by MD
• 95,460 points
3,709 views
0 votes
1 answer

How to retrieve the value of a text field in Flutter App?

Hi@akhtar, In your TextField, you can call one ...READ MORE

answered Sep 3, 2020 in Others by MD
• 95,460 points
1,731 views
0 votes
1 answer

How to add Icon to the TextField in Flutter App?

Hi@akhtar, You can add any Icon to your ...READ MORE

answered Sep 3, 2020 in Others by MD
• 95,460 points
5,231 views
0 votes
1 answer

How to Access Yoast SEO tags in Wordpress API Callback

use rest api to request for the ...READ MORE

answered Feb 12, 2022 in Others by narikkadan
• 63,720 points
1,783 views
0 votes
1 answer

Yoast SEO (WordPress Plugin) - Get plugin generated data manually

get_post_meta(), use this to get the meta ...READ MORE

answered Feb 11, 2022 in Others by narikkadan
• 63,720 points
1,446 views
0 votes
1 answer

Simple question regarding PHP, Wordpress & Yoast SEO

the way the search engine displays your ...READ MORE

answered Feb 14, 2022 in Others by narikkadan
• 63,720 points
463 views
0 votes
1 answer

how can I change yoast seo generated sitemap file URL?

plugins/wordpress-seo/inc/sitemaps/class-sitemaps-router.php go to this directory and change the ...READ MORE

answered Feb 22, 2022 in Others by narikkadan
• 63,720 points
3,475 views
0 votes
1 answer

Yoast Seo breadcrumbs: How to add custom text to category and tag name

use this code  add_filter('wpseo_breadcrumb_single_link', 'filter_breadcrumbs_for_h1', 10, 2); function filter_breadcrumbs_for_h1($link_output, ...READ MORE

answered Feb 12, 2022 in Others by narikkadan
• 63,720 points
637 views
0 votes
1 answer

Yoast Seo breadcrumbs: How to add custom text to category and tag name

add_filter('wpseo_breadcrumb_single_link', 'filter_breadcrumbs_for_h1', 10, 2); function filter_breadcrumbs_for_h1($link_output, $link) {     if ...READ MORE

answered Feb 25, 2022 in Others by narikkadan
• 63,720 points
1,422 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP