Posted By

lswilson on 01/20/12


post wordpress top types posts custom taxonomoy

Versions (?)

Top Posts: Custom Post Type/Taxonomy by Comment Count

 / Published in: PHP

WordPress top posts: custom post type / taxonomy Ordered by comment count

  1. global $blog_id;
  2. global $post;
  3. $tax = $taxonomy = strip_tags( get_the_term_list($post->ID, 'TAXONOMY_NAME') );
  4. $termies = get_the_terms( $post->id, 'TAXONOMY_NAME' );
  5. $terms_slugs = array();
  6. foreach( $termies as $term ) {
  7. $terms_slugs[] = $term->slug; // save the slugs in an array
  8. }
  9. echo '<h2 class="widgettitle">top from <span>'. $tax .'</span></h2><ul>';
  10. $query = array(
  11. 'post_type'=> 'POST_TYPE',
  12. 'taxonomy' => 'TAXONOMY_NAME',
  13. 'term' => $term->slug,
  14. 'orderby' => 'comment_count',
  15. 'showposts' => '5'
  16. );
  17. query_posts( $query );
  18. if (have_posts()) : while (have_posts()) : the_post();
  19. echo '<div class="top-posts">';
  20. echo '<li><a href="';
  21. echo the_permalink();
  22. echo '" title="';
  23. echo the_title();
  24. echo'"><div class="comment-img">';
  25. echo the_post_thumbnail('thumbnail');
  26. echo '</div></a>';
  27. echo '<a class="title" href="';
  28. echo the_permalink();
  29. echo '" title="';
  30. echo the_title();
  31. echo '">';
  32. echo the_title();
  33. echo '</a>';
  34. echo '<div class="author">';
  35. echo '<span>'. the_time(get_option('date_format')) .' by: </span>';
  36. echo the_author_posts_link();
  37. echo '</div>';
  38. endwhile; endif;
  39. wp_reset_query();
  40. echo '</ul>';
  41. echo '</div>';

Report this snippet  


RSS Icon Subscribe to comments
Posted By: lswilson on January 20, 2012

WordPress - Top Posts in Custom Post Type / Taxonomy ordered by comment count

Posted By: jaffa on June 19, 2012

Complete college or university courses and receive your degree in web design. This will include knowledge of html coding, which is essential when designing websites. Also work at a web development company to become familiar with every aspect of the business. Thanks. Regards, professional translation services

Posted By: emmiesneeks on August 22, 2012

Very useful post for me. It is exactly what I needed. Still can't believe that have found it. Thank you for providing me with WordPress top posts resume layout

Posted By: elizadd on July 30, 2017

wow, great, I was wondering how to cure acne naturally. and found your site by google, learned a lot, now i’m a bit clear. I’ve bookmark your site and also add rss. keep us updated.
Read Full Report

Posted By: robertfcrocker on July 30, 2017

Wow i can say that this is another great article as expected of this blog.Bookmarked this site.. over at this website

Posted By: elizadd on July 31, 2017

I’ve read some good stuff here. Definitely worth bookmarking for revisiting. I surprise how much effort you put to create such a great informative website. this link

Posted By: elizadd on August 2, 2017

Hi, I log on to your new stuff like every week. Your humoristic style is witty, keep it up
additional info

You need to login to post a comment.