Most Commented Page and Shortcode
Gary Come Home (18)
I am 36. (17)
Listening, Thinking, and Gestating. (14)
San Francisco Suggestions? (14)
Ché the Cat 1997-2006 (12)
Migrating an old Blogger blog to WordPress (12)
Today: The Day (11)
Posts That Might Be (11)
I’m 37. (11)
Mom and the Cancer (11)
My Name in Japanese, 1987 (10)
Are you a Respiratory Therapist? Do you blog? (10)
Nephrectomy (10)
Web pages are dead. Long live web pages. (If they’re made of people) (10)
Mom’s Cancer News (9)
Unsung: 7 Years Blogging (9)
Memo to myself. (8)
Joseph James Crawford (8)
Thank You All (8)
I added a “most commented” page to this site. This continues my evolutionary changing of this site.
In this post, the most commented posts are dynamic, because I added it as a shortcode to my theme. Here’s the code below (and also on github):
'; $posts_per_page = 150; query_posts('orderby=comment_count&posts_per_page='.$posts_per_page.'&order=DESC'); if ( have_posts() ) : while ( have_posts() ) : the_post(); echo ''; the_title(); echo ''; echo ' ('; comments_number('0','1','%'); echo ')
'; echo "\n"; endwhile; else : echo 'Sorry, no posts were found.
'; endif; echo ''; // reset the query so when I use it it doesn't // cause posts to be displayed query_posts('tag=NOTAREALTAG'); return $out; } add_shortcode('most_commented', 'mostCommented'); ?>
ArtLung : Using tags: “Drawings”; How I use WordPress get_the_image() ~ 27 Mar 2010
March 27, 2010 9:18am