Support » Fixing WordPress » echo custom taxonomy slug

  • Can anyone tell me how to echo the custom taxonomy slug? I need it to define a class. I’ve tried this over and over in a million different ways and nada… Im plain exhausted.

Viewing 1 replies (of 1 total)
  • BeantownDesign


    Check this post:

    I used code from there to make a link that would print the name of the custom taxonomy slug and also add a class to the link which is the name of the slug.

    $taxonomy = 'your_taxonomy_name_here';
    $terms = get_the_terms( $post->ID , $taxonomy );
    if ( !empty( $terms ) ) :
    foreach ( $terms as $term ) {
    	$link = get_term_link( $term, $taxonomy );
    	if ( !is_wp_error( $link ) )
    		echo '<a href="" rel="tag" class="' . $term->slug. '">' . $term->name . '</a>';
Viewing 1 replies (of 1 total)
  • The topic ‘echo custom taxonomy slug’ is closed to new replies.