I want to insert following custom code in single.php
can I set condition that if specific taxonomy exist then show and work this code otherwise not;
<div id="archivebox"> All courses in<?php echo get_the_term_list($post->ID,'country', ' ', ' ', '' ) ; ?><br>All courses in<?php echo get_the_term_list($post->ID,'institute', ' ', ' ', '' ) ; ?><br>All <?php echo get_the_term_list($post->ID,'subject', ' ', ' ', '', '' ) ; ?> courses worldwide<br>All<?php echo get_the_term_list($post->ID,'qualification', ' ', ' ', '' ) ; ?> courses worldwide<br>Alphabetical List: <?php echo get_the_term_list($post->ID,'alphabetical', ' ', ' ', '' ) ; ?> worldwide</div>
If you want to check for the existence of a taxonomy, use
taxonomy_exists( $taxonomy )
:etc…
Edit
If, instead of checking for the existence of a taxonomy, you want to check if the current post belongs to a taxonomy, use
get_the_term_list( $post->ID, $taxonomy )
:To avoid duplicate post I’ll answer here:
Edited according comments below.