Skip to content

Instantly share code, notes, and snippets.

@celticwebdesign
Created September 17, 2017 17:53
Show Gist options
  • Save celticwebdesign/508d518a82d355eae040464a301c7a2b to your computer and use it in GitHub Desktop.
Save celticwebdesign/508d518a82d355eae040464a301c7a2b to your computer and use it in GitHub Desktop.
function get_all_categories($taxonomy) {
$terms = get_terms(
array(
'taxonomy' => $taxonomy,
'hide_empty' => false,
)
);
if ( $terms && ! is_wp_error( $terms ) ) :
$output = "";
$draught_links = array();
foreach ( $terms as $term ) {
$term_link = get_term_link( $term );
$draught_links[] = $term->name;
$output .= "<span>
<a href='".$term_link."'>".$term->name."</a>
</span>";
}
$on_draught = join( " ", $draught_links );
return $output;
endif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment