• Resolved Rose

    (@eos-rose)


    I have many posts that contain audio content. I’ve created the custom taxonomy ‘duration_span’, which allows me to group audio posts into half-hour increments. I’ve also created the custom field ‘duration’, which allows me to display the specific duration for each audio post. I would like to display the ‘duration’ custom field as a link to the ‘duration_span’ custom category.

    In functions.php, I have attempted to use the following functions:

    if(!function_exists('duration')){
    	function duration(){
    		global $post;
    		$terms = get_terms('duration_span');
    		echo '<ul class="catlist">';
    		foreach ($terms as $term) {
    			echo '<li><a href="'.get_term_link($term->slug, 'duration_span').'">'.get_post_meta($post->ID, 'duration', true).'</a></li>';
    		}
    		echo '</ul> || ';
    	}
    }

    The function above gives me a list of ALL possible ‘duration_span’ categories WHETHER OR NOT THE POST IS WITHIN THOSE CATEGORIES. The specific duration does display as the link text.

    `if(!function_exists(‘duration’)){
    function duration(){
    global $post;
    echo ‘ || <ul class=”catlist”>’;
    echo get_the_term_list( $post->ID, ‘duration_span’, ‘

    • ‘, ‘
    • ‘, ‘
    • ‘ );
      echo ”;
      }
      }
      The function above displays only the applicable ‘duration_span’ category, but does not seem to allow me any way to change the link text to the content of the ‘duration’ custom field.

      I’m not sure how to proceed from here. Suggestions would be most welcome!

  • The topic ‘get_the_term_list() or get_term_link() issue?’ is closed to new replies.