/ Published in: PHP
WordPress top posts: custom post type / taxonomy
Ordered by comment count
Ordered by comment count
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
global $blog_id; global $post; $termies = get_the_terms( $post->id, 'TAXONOMY_NAME' ); foreach( $termies as $term ) { $terms_slugs[] = $term->slug; // save the slugs in an array } echo '<h2 class="widgettitle">top from <span>'. $tax .'</span></h2><ul>'; 'post_type'=> 'POST_TYPE', 'taxonomy' => 'TAXONOMY_NAME', 'term' => $term->slug, 'orderby' => 'comment_count', 'showposts' => '5' ); query_posts( $query ); if (have_posts()) : while (have_posts()) : the_post(); echo '<div class="top-posts">'; echo '<li><a href="'; echo the_permalink(); echo '" title="'; echo the_title(); echo'"><div class="comment-img">'; echo the_post_thumbnail('thumbnail'); echo '</div></a>'; echo '<a class="title" href="'; echo the_permalink(); echo '" title="'; echo the_title(); echo '">'; echo the_title(); echo '</a>'; echo '<div class="author">'; echo '<span>'. the_time(get_option('date_format')) .' by: </span>'; echo the_author_posts_link(); echo '</div>'; endwhile; endif; wp_reset_query(); echo '</ul>'; echo '</div>';