0

For a custom post type (review) I have enabled a few custom taxonomies. One of them is author rating and for that I have added images to the description field of the terms in the taxonomy (1 star to 5 stars).

Now I am wondering how to show that description instead of the term itself on the single-review.php?

I am already using the function to allow XHTML in category descriptions as per Justin Tadlock's function described on his website

  • Could you please show the code from single-review.php? – kaiser Jun 14 '11 at 11:11
  • sure, you can find it on: pastebin.com/K12Npptz I wrote in Capitals where I would like to show the description of the term instead of the term itself – user2015 Jun 14 '11 at 11:44
  • Take a look at /wp-includes/category-template.php on line 1113 and the filter "term_links-$taxonomy". – kaiser Jun 14 '11 at 12:56
  • @kaiser, I am not sure I follow you. The filter says $term_links = apply_filters( "term_links-$taxonomy", $term_links ); I have to wiggle description somewhere in there? – user2015 Jun 14 '11 at 13:29
  • take a look at this – kaiser Jun 14 '11 at 14:03
1

If i understand correctly what you are trying to achieve then you can use get_the_terms function to get the rating terms object and from that echo out the description.

replace:

<?php echo get_the_term_list( $post->ID, 'rating', __('Author Rating: ', 'appz'), ', ', '' ); // HERE I WANT THE DESCRIPTION (I.E. THE IMAGE THAT I USED AS THE DESCRIPTION INSTEAD OF THE TERM) ?>

with:

<?php 
    echo '<span class="rating-author">'.__('Author Rating: ', 'appz').'</span>';

    $reating_terms = get_the_terms ($post->id, 'rating');
    foreach ($reating_terms as $term){
        echo $term->description;
    }
    ?>
  • Thank you @Bainternet, that is exactly what I wanted to accomplish! To let me understand what you did to accomplish this result, you basically created a new filter, correct? I still have to learn that you can basically create any type of filter this way... What I don't understand though is why there is no need to end the foreach... – user2015 Jun 14 '11 at 15:13
  • no filter here , just queried the terms of the taxonomy 'rating' that this post have. as for the foreach, you can end it with foreach($bs as $b) : //doo stuf end foreach or use brackets foreach($bs as $b) { //doo stuf } – Bainternet Jun 14 '11 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy