<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How to count posts in multiple categories for WordPress</title>
	<atom:link href="http://webdosanddonts.com/how-to-count-posts-in-multiple-categories-for-wordpress/feed" rel="self" type="application/rss+xml" />
	<link>http://webdosanddonts.com/how-to-count-posts-in-multiple-categories-for-wordpress</link>
	<description>Tips&#38;Tricks for the modern day web designer</description>
	<lastBuildDate>Tue, 13 Jul 2010 07:27:17 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: Lucius</title>
		<link>http://webdosanddonts.com/how-to-count-posts-in-multiple-categories-for-wordpress/comment-page-1#comment-1205</link>
		<dc:creator>Lucius</dc:creator>
		<pubDate>Sun, 11 Jul 2010 21:57:40 +0000</pubDate>
		<guid isPermaLink="false">http://webdosanddonts.com/?p=581#comment-1205</guid>
		<description>Very useful, thank you very much!</description>
		<content:encoded><![CDATA[<p>Very useful, thank you very much!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: courtenaya</title>
		<link>http://webdosanddonts.com/how-to-count-posts-in-multiple-categories-for-wordpress/comment-page-1#comment-1182</link>
		<dc:creator>courtenaya</dc:creator>
		<pubDate>Mon, 10 May 2010 18:27:46 +0000</pubDate>
		<guid isPermaLink="false">http://webdosanddonts.com/?p=581#comment-1182</guid>
		<description>scale impact intensity gps</description>
		<content:encoded><![CDATA[<p>scale impact intensity gps</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: disney mp3 players</title>
		<link>http://webdosanddonts.com/how-to-count-posts-in-multiple-categories-for-wordpress/comment-page-1#comment-1122</link>
		<dc:creator>disney mp3 players</dc:creator>
		<pubDate>Fri, 26 Feb 2010 10:59:25 +0000</pubDate>
		<guid isPermaLink="false">http://webdosanddonts.com/?p=581#comment-1122</guid>
		<description>Nice post. Love your work hope to see some more cool stuff soon.</description>
		<content:encoded><![CDATA[<p>Nice post. Love your work hope to see some more cool stuff soon.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://webdosanddonts.com/how-to-count-posts-in-multiple-categories-for-wordpress/comment-page-1#comment-1120</link>
		<dc:creator>James</dc:creator>
		<pubDate>Sun, 31 Jan 2010 16:01:36 +0000</pubDate>
		<guid isPermaLink="false">http://webdosanddonts.com/?p=581#comment-1120</guid>
		<description>Absolutely fabulous! Huge amounts of thanks due!</description>
		<content:encoded><![CDATA[<p>Absolutely fabulous! Huge amounts of thanks due!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brady J. Frey</title>
		<link>http://webdosanddonts.com/how-to-count-posts-in-multiple-categories-for-wordpress/comment-page-1#comment-1107</link>
		<dc:creator>Brady J. Frey</dc:creator>
		<pubDate>Fri, 08 Jan 2010 17:21:20 +0000</pubDate>
		<guid isPermaLink="false">http://webdosanddonts.com/?p=581#comment-1107</guid>
		<description>Very useful, thank you - I&#039;ve been looking for a way to filter the count, something http://codex.wordpress.org/Function_Reference/wp_count_posts lacks!</description>
		<content:encoded><![CDATA[<p>Very useful, thank you &#8211; I&#8217;ve been looking for a way to filter the count, something <a href="http://codex.wordpress.org/Function_Reference/wp_count_posts" rel="nofollow">http://codex.wordpress.org/Function_Reference/wp_count_posts</a> lacks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Siniša</title>
		<link>http://webdosanddonts.com/how-to-count-posts-in-multiple-categories-for-wordpress/comment-page-1#comment-1105</link>
		<dc:creator>Siniša</dc:creator>
		<pubDate>Thu, 07 Jan 2010 22:29:56 +0000</pubDate>
		<guid isPermaLink="false">http://webdosanddonts.com/?p=581#comment-1105</guid>
		<description>Yup, that is a great example of expanding this. Glad you found it useful.</description>
		<content:encoded><![CDATA[<p>Yup, that is a great example of expanding this. Glad you found it useful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tzs</title>
		<link>http://webdosanddonts.com/how-to-count-posts-in-multiple-categories-for-wordpress/comment-page-1#comment-1104</link>
		<dc:creator>tzs</dc:creator>
		<pubDate>Sun, 03 Jan 2010 23:14:08 +0000</pubDate>
		<guid isPermaLink="false">http://webdosanddonts.com/?p=581#comment-1104</guid>
		<description>Thx! I was search this!

It works if you can count posts by categories for an author:

function wdd_in_category_count($catslugs = &#039;&#039;, $display = true) {
	global $wpdb;

	$post_count = 0;
	$slug_where = &#039;&#039;;
	$catslugs_arr = split(&#039;,&#039;, $catslugs);

 	foreach ($catslugs_arr as $catslugkey =&gt; $catslug) {
		if ( $catslugkey &gt; 0 ) {
			$slug_where .= &#039;, &#039;;
		 }

 		$slug_where .= &quot;&#039;&quot; . trim($catslug) . &quot;&#039;&quot;;
	}

	$slug_where = &quot;cat_terms.slug IN (&quot; . $slug_where . &quot;)&quot;;

	$sql =	&quot;SELECT	COUNT( DISTINCT cat_posts.ID ) AS post_count &quot; .
		&quot;FROM 	&quot; . $wpdb-&gt;term_taxonomy . &quot; AS cat_term_taxonomy INNER JOIN &quot; . $wpdb-&gt;terms . &quot; AS cat_terms ON &quot; .
				&quot;cat_term_taxonomy.term_id = cat_terms.term_id &quot; .
			&quot;INNER JOIN &quot; . $wpdb-&gt;term_relationships . &quot; AS cat_term_relationships ON &quot; .
				&quot;cat_term_taxonomy.term_taxonomy_id = cat_term_relationships.term_taxonomy_id &quot; .
			&quot;INNER JOIN &quot; . $wpdb-&gt;posts . &quot; AS cat_posts ON &quot; .
				&quot;cat_term_relationships.object_id = cat_posts.ID &quot; .
		&quot;WHERE 	cat_posts.post_status = &#039;publish&#039; AND &quot; .
			&quot;cat_posts.post_type = &#039;post&#039; AND &quot; .
			&lt;b&gt;&quot;cat_posts.post_author = &#039;&quot;.get_the_author_id().&quot;&#039; AND &quot; .&lt;/b&gt;
			&quot;cat_term_taxonomy.taxonomy = &#039;category&#039; AND &quot; .
			$slug_where;

	$post_count = $wpdb-&gt;get_var($sql);

	if ( $display ) {
		echo $post_count;
	} 

	return $post_count; 

}</description>
		<content:encoded><![CDATA[<p>Thx! I was search this!</p>
<p>It works if you can count posts by categories for an author:</p>
<p>function wdd_in_category_count($catslugs = &#8221;, $display = true) {<br />
	global $wpdb;</p>
<p>	$post_count = 0;<br />
	$slug_where = &#8221;;<br />
	$catslugs_arr = split(&#8216;,&#8217;, $catslugs);</p>
<p> 	foreach ($catslugs_arr as $catslugkey =&gt; $catslug) {<br />
		if ( $catslugkey &gt; 0 ) {<br />
			$slug_where .= &#8216;, &#8216;;<br />
		 }</p>
<p> 		$slug_where .= &#8220;&#8216;&#8221; . trim($catslug) . &#8220;&#8216;&#8221;;<br />
	}</p>
<p>	$slug_where = &#8220;cat_terms.slug IN (&#8221; . $slug_where . &#8220;)&#8221;;</p>
<p>	$sql =	&#8220;SELECT	COUNT( DISTINCT cat_posts.ID ) AS post_count &#8221; .<br />
		&#8220;FROM 	&#8221; . $wpdb-&gt;term_taxonomy . &#8221; AS cat_term_taxonomy INNER JOIN &#8221; . $wpdb-&gt;terms . &#8221; AS cat_terms ON &#8221; .<br />
				&#8220;cat_term_taxonomy.term_id = cat_terms.term_id &#8221; .<br />
			&#8220;INNER JOIN &#8221; . $wpdb-&gt;term_relationships . &#8221; AS cat_term_relationships ON &#8221; .<br />
				&#8220;cat_term_taxonomy.term_taxonomy_id = cat_term_relationships.term_taxonomy_id &#8221; .<br />
			&#8220;INNER JOIN &#8221; . $wpdb-&gt;posts . &#8221; AS cat_posts ON &#8221; .<br />
				&#8220;cat_term_relationships.object_id = cat_posts.ID &#8221; .<br />
		&#8220;WHERE 	cat_posts.post_status = &#8216;publish&#8217; AND &#8221; .<br />
			&#8220;cat_posts.post_type = &#8216;post&#8217; AND &#8221; .<br />
			<b>&#8220;cat_posts.post_author = &#8216;&#8221;.get_the_author_id().&#8221;&#8216; AND &#8221; .</b><br />
			&#8220;cat_term_taxonomy.taxonomy = &#8216;category&#8217; AND &#8221; .<br />
			$slug_where;</p>
<p>	$post_count = $wpdb-&gt;get_var($sql);</p>
<p>	if ( $display ) {<br />
		echo $post_count;<br />
	} </p>
<p>	return $post_count; </p>
<p>}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kouba</title>
		<link>http://webdosanddonts.com/how-to-count-posts-in-multiple-categories-for-wordpress/comment-page-1#comment-129</link>
		<dc:creator>Kouba</dc:creator>
		<pubDate>Mon, 30 Nov 2009 08:55:22 +0000</pubDate>
		<guid isPermaLink="false">http://webdosanddonts.com/?p=581#comment-129</guid>
		<description>Are you a professional journalist? You write very well.</description>
		<content:encoded><![CDATA[<p>Are you a professional journalist? You write very well.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
