Posts

Showing posts from December, 2024

Google Breadcrumbs Schema Markup for Grads24

 add_filter('wpseo_breadcrumb_single_link', function($link_output, $link) {     // If the link is the current item, ensure it has an "item" URL     if (isset($link['url']) && empty($link['url'])) {         $link['url'] = get_permalink(); // Use the current page URL     }     return $link_output; }, 10, 2); add_filter('wpseo_schema_breadcrumb', function($data) {     // Ensure the current page has an "item" URL in schema     $breadcrumbs = $data['itemListElement'];     foreach ($breadcrumbs as $index => $breadcrumb) {         if (!isset($breadcrumb['item']) || empty($breadcrumb['item'])) {             $breadcrumbs[$index]['item'] = get_permalink();         }     }     $data['itemListElement'] = $breadcrumbs;     return $data; });