Return to Snippet

Revision: 54985
at January 20, 2012 08:36 by lswilson


Initial Code
global $blog_id;
	global $post;
		$tax = $taxonomy = strip_tags( get_the_term_list($post->ID, 'TAXONOMY_NAME') );
		$termies = get_the_terms( $post->id, 'TAXONOMY_NAME' ); 
		$terms_slugs = array();
		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>';
		$query = array(
			'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>';

Initial URL

                                

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

Initial Title
Top Posts:  Custom Post Type/Taxonomy by Comment Count

Initial Tags
post, wordpress

Initial Language
PHP