• I need a help please,

    I used this code to get term list of my custom taxonomies:

    <?php echo get_the_term_list( get_the_ID(), 'similar', '', '', '' ); ?>

    the problem is the output will be error and break the page when no term is found from my custom taxonomies, there is a way to display nothing when the post is doesn’t have term?

    Thanks.

    [Please post code snippets between backticks or use the code button.]

Viewing 1 replies (of 1 total)
  • function custom_get_the_term_list( $post_id, $taxonomy_name, $taxonomy_label ) {
    	if( get_the_term_list( $post->ID, $taxonomy_name ) ) {
    		return get_the_term_list( $post->ID, $taxonomy_name, '<li><label>' . $taxonomy_label . '</label>: ', ', ', '</li>' );
    	}
    }

    ^^This function seems to do the trick

Viewing 1 replies (of 1 total)

The topic ‘Problem with get the term list’ is closed to new replies.