Last active
April 4, 2020 00:11
-
-
Save rali14/1a08c82ac7fe555743031e14abe09656 to your computer and use it in GitHub Desktop.
Shortcode to display Course Tags - LearnDash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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