How to test if the tag list is empty for the current page?


I have three custom taxonomies (topic, name, simile) Currently I display the list of tags in each taxonomy for the current post at the bottom of the post. That works fine. But I would like to give each taxonomy a heading, but only if there is something displayed for that taxonomy.

I am currently doing a similar thing with custom fields. For example the further-reading field:

    $my_furtherReading = get_post_meta( get_the_ID(), 'further-reading', true);

    if( ! empty( $my_furtherReading ) ) {
        echo '<div class="furtherReading"><h2>Further Reading:</h2>' . $my_furtherReading . '</div>';

It only prints the heading if the field is not empty.

This is how I am displaying my taxonomies (topic taxonomy)

echo get_the_term_list( $post->ID, 'topic',
'', ' ', '' );

Is there a function to test if the tag list is empty? If so, could someone be kind enough to show me how to use it?

HopefullCoder 3 years 2020-03-31T04:51:25-05:00 0 Answers 63 views 0

Leave an answer