Last active
August 14, 2023 04:16
-
-
Save rali14/c9c5e9ea6d2ff057c50559a7dd5f23a1 to your computer and use it in GitHub Desktop.
Shortcode to Display Course Categories
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_categories ($atts) { | |
$terms = get_the_terms( get_the_ID() , 'ld_course_category' ); | |
if (!$terms) { | |
// No terms, so just quit. | |
return false; | |
} | |
$categories= ""; | |
foreach ( $terms as $term ) { | |
$categories .= ", " . "<a href='" . get_term_link($term) . "'>" . $term->name ."</a>"; | |
} | |
return "<span class='ld-course-categories'>" . trim($categories, ",") . "</span>"; | |
} | |
add_shortcode( 'ld_course_categories', 'ld_display_course_categories' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment