Skip to content

Instantly share code, notes, and snippets.

@annelyse
Created August 4, 2021 11:31
Show Gist options
  • Save annelyse/1c6e8ecc8d6dec9da927dea759f2769d to your computer and use it in GitHub Desktop.
Save annelyse/1c6e8ecc8d6dec9da927dea759f2769d to your computer and use it in GitHub Desktop.
<?php
add_filter( 'wpseo_breadcrumb_links', 'unbox_yoast_seo_breadcrumb_append_link' );
function unbox_yoast_seo_breadcrumb_append_link( $links ) {
global $post;
if( is_singular('cpt_events')){
$date_maintenant = date('Y-m-d H:i:s');
$event_date_start = get_field('event_date_start', $post->ID) ;
$event_date_end = get_field('event_date_end', $post->ID) ;
if( ( $date_maintenant <= $event_date_start) && ($date_maintenant <= $event_date_end )){
$url = get_permalink(418);
$text = get_the_title(418);
}else{
$url = get_permalink(421);
$text = get_the_title(421);
}
$breadcrumb = array(
'url' => $url,
'text' => $text,
);
array_splice( $links, -1, 0, array( $breadcrumb) );
}
return $links;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment