Smorgasborg - Random Objects

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'); ?>

posted this 13 years ago.
What else did he post in March 2010?

(Thursday March 18th 2010 at 10:02am)

Comments: 2

Leave me a comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.