function dm_display_wpjm_categories () { | |
$terms = get_terms( array( | |
'taxonomy' => 'job_listing_category', | |
'hide_empty' => false, | |
) ); | |
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){ | |
echo '<ul>'; | |
foreach ( $terms as $term ) { | |
echo '<li>' . '<a href="' . esc_url( get_term_link( $term ) ) . '">' . $term->name . '</a></li>'; | |
} | |
echo '</ul>'; | |
} | |
} | |
add_shortcode('list_categories', 'dm_display_wpjm_categories'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Great snippet. My only suggestion/improvement is to use Output Buffering so this shortcode can be used anywhere on the page. Here is my version:
Hope this helps someone who had the same issue as me.