Skip to content

Instantly share code, notes, and snippets.

@jocastaneda
Created July 30, 2018 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jocastaneda/44b876cf3ee9e0de683435c93ca4f6b9 to your computer and use it in GitHub Desktop.
Save jocastaneda/44b876cf3ee9e0de683435c93ca4f6b9 to your computer and use it in GitHub Desktop.
<?php // add_shortcode needs to return a string.
function tags_function() {
$termsSecteur = get_the_terms( $post->ID , 'secteur' );
if ( $termsSecteur != null ) {
foreach ( $termsSecteur as $termsSecteur ) {
$termsSecteur_link = get_term_link( $termsSecteur, 'secteur' );
$return .= sprintf( '<a class="tag-secteur" href="%1$s">%2$s</a>', $termsSecteur_link, $termsSecteur->name );
unset( $termsSecteur );
}
}
return $return;
}
add_shortcode( 'list_tags', 'tags_function' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment