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: alicianewman148 on May 29, 2018

Hello everyone, I just have to say that this site is just amazing. Much creative and extremely curricular website I have ever found while looking for Dissertation Help on the web. I am very pleased with their work, efforts and creativity, everything looked very well and kept. I appreciate your work, keep up a great job.

Posted By: ankie147 on June 9, 2018

In my personal work i used many type of the coding language play yahtzee free online but for the support only a one place where have very vredible codes I can get for my work properly.

You need to login to post a comment.