<?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>Thu, 29 Mar 2012 07:29:18 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: Mark</title>
		<link>http://webdosanddonts.com/how-to-count-posts-in-multiple-categories-for-wordpress/comment-page-1#comment-1309</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Wed, 28 Mar 2012 06:53:20 +0000</pubDate>
		<guid isPermaLink="false">http://webdosanddonts.com/?p=581#comment-1309</guid>
		<description>Sorry, posted that before seeing this line: &quot;cat_posts.post_type = &#039;post&#039; AND &quot; .

Is there a way to make it so that only posts that reside in both categories simultaneously are counted?</description>
		<content:encoded><![CDATA[<p>Sorry, posted that before seeing this line: &#8220;cat_posts.post_type = &#8216;post&#8217; AND &#8221; .</p>
<p>Is there a way to make it so that only posts that reside in both categories simultaneously are counted?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://webdosanddonts.com/how-to-count-posts-in-multiple-categories-for-wordpress/comment-page-1#comment-1308</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Wed, 28 Mar 2012 06:40:08 +0000</pubDate>
		<guid isPermaLink="false">http://webdosanddonts.com/?p=581#comment-1308</guid>
		<description>Is there any way to expand this so that it works with custom post types as well?

Thanks!</description>
		<content:encoded><![CDATA[<p>Is there any way to expand this so that it works with custom post types as well?</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Henry</title>
		<link>http://webdosanddonts.com/how-to-count-posts-in-multiple-categories-for-wordpress/comment-page-1#comment-1297</link>
		<dc:creator>Henry</dc:creator>
		<pubDate>Tue, 28 Feb 2012 19:36:24 +0000</pubDate>
		<guid isPermaLink="false">http://webdosanddonts.com/?p=581#comment-1297</guid>
		<description>Do you have an example of this? I am not a coder but think I know what the code achieves. I&#039;d like like to see it in action first and then implement.

Cheers</description>
		<content:encoded><![CDATA[<p>Do you have an example of this? I am not a coder but think I know what the code achieves. I&#8217;d like like to see it in action first and then implement.</p>
<p>Cheers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexk</title>
		<link>http://webdosanddonts.com/how-to-count-posts-in-multiple-categories-for-wordpress/comment-page-1#comment-1295</link>
		<dc:creator>Alexk</dc:creator>
		<pubDate>Wed, 01 Feb 2012 13:08:06 +0000</pubDate>
		<guid isPermaLink="false">http://webdosanddonts.com/?p=581#comment-1295</guid>
		<description>hello
thank you for your code,
I need a code for count posts joint in two categories , your way count all posts but I need only joint posts.

how can i do this ?</description>
		<content:encoded><![CDATA[<p>hello<br />
thank you for your code,<br />
I need a code for count posts joint in two categories , your way count all posts but I need only joint posts.</p>
<p>how can i do this ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harsh maur</title>
		<link>http://webdosanddonts.com/how-to-count-posts-in-multiple-categories-for-wordpress/comment-page-1#comment-1270</link>
		<dc:creator>Harsh maur</dc:creator>
		<pubDate>Mon, 19 Sep 2011 12:05:19 +0000</pubDate>
		<guid isPermaLink="false">http://webdosanddonts.com/?p=581#comment-1270</guid>
		<description>hey really found useful i was actually struck with the custom taxonomy count as it always showed published as well as drafts. I hope this code will work</description>
		<content:encoded><![CDATA[<p>hey really found useful i was actually struck with the custom taxonomy count as it always showed published as well as drafts. I hope this code will work</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Job</title>
		<link>http://webdosanddonts.com/how-to-count-posts-in-multiple-categories-for-wordpress/comment-page-1#comment-1257</link>
		<dc:creator>Job</dc:creator>
		<pubDate>Tue, 09 Aug 2011 13:26:23 +0000</pubDate>
		<guid isPermaLink="false">http://webdosanddonts.com/?p=581#comment-1257</guid>
		<description>If you want to do something similar but without poking around with SQL, you can use WordPress&#039; oqn query function to achieve the same result:

&lt;code&gt;
// $ids is an array of all IDs you want to check overlap of
function category_overlap_count($ids){
	$query = array();
	$query[&#039;category__and&#039;] = $ids; // This filters our query to include only posts that are in ALL of the specified queries
	$query[&#039;posts_per_page&#039;] = -1; // Making sure we select all posts (and not limit the query by our regular post per page setting)

	$results = get_posts( $query ); // Run the query

	$i = count($results); // Count the results

	return $i; // Return the count
}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>If you want to do something similar but without poking around with SQL, you can use WordPress&#8217; oqn query function to achieve the same result:</p>
<p><code><br />
// $ids is an array of all IDs you want to check overlap of<br />
function category_overlap_count($ids){<br />
	$query = array();<br />
	$query['category__and'] = $ids; // This filters our query to include only posts that are in ALL of the specified queries<br />
	$query['posts_per_page'] = -1; // Making sure we select all posts (and not limit the query by our regular post per page setting)</p>
<p>	$results = get_posts( $query ); // Run the query</p>
<p>	$i = count($results); // Count the results</p>
<p>	return $i; // Return the count<br />
}<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zdenek</title>
		<link>http://webdosanddonts.com/how-to-count-posts-in-multiple-categories-for-wordpress/comment-page-1#comment-1246</link>
		<dc:creator>Zdenek</dc:creator>
		<pubDate>Sat, 16 Apr 2011 14:41:20 +0000</pubDate>
		<guid isPermaLink="false">http://webdosanddonts.com/?p=581#comment-1246</guid>
		<description>Very helpful. Thank you. Vielen Dank. Спасибо. ありがとうございます. Dekuji. Merci!</description>
		<content:encoded><![CDATA[<p>Very helpful. Thank you. Vielen Dank. Спасибо. ありがとうございます. Dekuji. Merci!</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-1239</link>
		<dc:creator>Siniša</dc:creator>
		<pubDate>Tue, 18 Jan 2011 21:06:04 +0000</pubDate>
		<guid isPermaLink="false">http://webdosanddonts.com/?p=581#comment-1239</guid>
		<description>Nema frke, imenjače... Traži, traži, pa ćeš naći :)</description>
		<content:encoded><![CDATA[<p>Nema frke, imenjače&#8230; Traži, traži, pa ćeš naći :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sinisa</title>
		<link>http://webdosanddonts.com/how-to-count-posts-in-multiple-categories-for-wordpress/comment-page-1#comment-1238</link>
		<dc:creator>Sinisa</dc:creator>
		<pubDate>Tue, 18 Jan 2011 13:35:25 +0000</pubDate>
		<guid isPermaLink="false">http://webdosanddonts.com/?p=581#comment-1238</guid>
		<description>Hvala brate, veoma je korisno. Ovo sam ganjao po celom netu.</description>
		<content:encoded><![CDATA[<p>Hvala brate, veoma je korisno. Ovo sam ganjao po celom netu.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: danielle</title>
		<link>http://webdosanddonts.com/how-to-count-posts-in-multiple-categories-for-wordpress/comment-page-1#comment-1226</link>
		<dc:creator>danielle</dc:creator>
		<pubDate>Wed, 13 Oct 2010 15:43:59 +0000</pubDate>
		<guid isPermaLink="false">http://webdosanddonts.com/?p=581#comment-1226</guid>
		<description>thank you. thank you. thank you.</description>
		<content:encoded><![CDATA[<p>thank you. thank you. thank you.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

