Created
June 3, 2017 23:30
-
-
Save davoraltman/fbcac2ddbfdff815df71ad4b7a582947 to your computer and use it in GitHub Desktop.
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 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'); |
Hi really new to this. Does this snippet go in functions.php? From a beginner point of view it is always nice to see the filename in the comments. :-)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.