Skip to content

Instantly share code, notes, and snippets.

@cotasson
Created January 27, 2021 00:47
Show Gist options
  • Save cotasson/572cd97910ab2df65b3f191306ab634c to your computer and use it in GitHub Desktop.
Save cotasson/572cd97910ab2df65b3f191306ab634c to your computer and use it in GitHub Desktop.
//based on https://generatepress.com/forums/topic/add-acf-custom-fields-to-a-post-excerpt/
//add country to voyage CPT excerpt
add_filter( 'the_excerpt', function( $excerpt ) {
$terms = get_the_terms(get_the_ID(), 'pays');
foreach ($terms as $term) {
$term_link = get_term_link($term, 'pays');
if (is_wp_error($term_link))
continue;
$country_link ='<a class="linkAsButton" href="' . $term_link . '">' . $term->name . '</a><br/> ';
}
return $excerpt . $country_link;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment