Skip to content

Instantly share code, notes, and snippets.

@MervinPraison
Last active December 23, 2016 11:08
Show Gist options
  • Save MervinPraison/61df17e1346f977362b4e6109bf83a10 to your computer and use it in GitHub Desktop.
Save MervinPraison/61df17e1346f977362b4e6109bf83a10 to your computer and use it in GitHub Desktop.
breadcrumb-filter.php
// define the wpseo_breadcrumb_single_link callback
function filter_wpseo_breadcrumb_single_link( $link_output, $link ) {
// make filter magic happen here...
foreach($link_output as $keys => $link_out ){
foreach ($link_out as $key=>$value) {
if($key=='term') {
if(get_term_meta( $value->term_taxonomy_id, 'post_url', true ))
{
$replace = array('text' => $link_output[$keys][$key]->name, 'url' => get_term_meta( $value->term_taxonomy_id, 'initiated_url', true ), 'allow_html' => '1');
$link_output[$keys] = $replace;
}
}
}
}
return $link_output;
};
// add the filter
add_filter( 'wpseo_breadcrumb_links', 'filter_wpseo_breadcrumb_single_link', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment