Skip to content

Instantly share code, notes, and snippets.

@lukecav
Forked from theJasonJones/wp-seo-tweaks.php
Created August 16, 2016 20:12
Show Gist options
  • Select an option

  • Save lukecav/ba2937c3e2b67d529d55973d76aeb0c9 to your computer and use it in GitHub Desktop.

Select an option

Save lukecav/ba2937c3e2b67d529d55973d76aeb0c9 to your computer and use it in GitHub Desktop.
Had to a few tweaks to the WP-SEO breadcrumbs. This is what I did.
<?php
// Remove the last link in breadcrumbs
// WHY? Because it an span tag that contains the title of the page
// But you're already on the page, so what's the point?
add_filter( 'wpseo_breadcrumb_links', 'jj_wpseo_breadcrumb_links' );
function jj_wpseo_breadcrumb_links( $links ) {
//pk_print( sizeof($links) );
if( sizeof($links) > 1 ){
array_pop($links);
}
return $links;
}
// Add link to the last item in the breadcrumbs
// WHY? Because, by default, WP-SEO doesn't include the link on the last item
// Since we removed in the function above, we need to add the link back in.
add_filter( 'wpseo_breadcrumb_single_link', 'jj_link_to_last_crumb' , 10, 2);
function jj_link_to_last_crumb( $output, $crumb){
$output = '<a property="v:title" rel="v:url" href="'. $crumb['url']. '" >';
$output.= $crumb['text'];
$output.= '</a>';
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment