-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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