Skip to content

Instantly share code, notes, and snippets.

@rali14
Last active April 4, 2020 00:11
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 rali14/1a08c82ac7fe555743031e14abe09656 to your computer and use it in GitHub Desktop.
Save rali14/1a08c82ac7fe555743031e14abe09656 to your computer and use it in GitHub Desktop.
Shortcode to display Course Tags - LearnDash
function ld_display_course_tags ($atts) {
$terms = get_the_terms( get_the_ID() , 'ld_course_tags' );
if (!$terms) {
// No terms, so just quit.
return false;
}
$tags= "";
foreach ( $terms as $term ) {
$tags .= ", " . "<a href='" . get_term_link($term) . "'>" . $term->name ."</a>";
}
return "<span class='ld-course-tags'>" . trim($tags, ",") . "</span>";
}
add_shortcode( 'ld_course_tags', 'ld_display_course_tags' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment