<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>threeformed // a blog &#187; hack</title>
	<atom:link href="http://threeformed.com/blog/tag/hack/feed/" rel="self" type="application/rss+xml" />
	<link>http://threeformed.com/blog</link>
	<description></description>
	<lastBuildDate>Fri, 18 Feb 2011 20:00:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Get page tag id&#8217;s based on a category in WordPress</title>
		<link>http://threeformed.com/blog/get-page-tag-ids-based-on-a-category-in-wordpress/</link>
		<comments>http://threeformed.com/blog/get-page-tag-ids-based-on-a-category-in-wordpress/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 02:56:00 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[hack]]></category>

		<guid isPermaLink="false">http://threeformed.com/blog/2009/10/27/get-page-tag-ids-based-on-a-category-in-wordpress/</guid>
		<description><![CDATA[<p>For the new threeformed site I am using WordPress as a light CMS, so I wanted to treat some &#8216;special&#8217; posts d&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>For the new threeformed site I am using WordPress as a light CMS, so I wanted to treat some &#8216;special&#8217; posts differently than others based on their category. This meant that i&#8217;d have to exclude these &#8216;special&#8217; posts from a few places, one of these places was the tag cloud.<span id="more-20"></span><br />
Hmmm, I can only exclude tags from</p>
<pre><code>wp_tag_cloud()</code></pre>
<p>based on ID&#8217;s? So that seemed easy enough right?! I could just use</p>
<pre><code>get_the_tag_ids('exclude=special')</code></pre>
<p>&#8230; Well if that function existed. Well it does now!</p>
<pre><code>
// Gets tags ID's for current post
	function get_the_tag_ids($which, $delimiter) {
		// Gets posts for the category
		query_posts('category_name='.$which);
		// Loop through each post with $which category
		while(have_posts()) {
			the_post();
			// Get the tags for each post
			$this_post_tags = get_the_tags();
			// if there are tags
			if ($this_post_tags) {
				// Get the tag ID for each
				foreach($this_post_tags as $tag) {
					$taxarray = is_term($tag-&gt;name, 'post_tag');
					$post_tags .= $taxarray[term_id].$delimiter;
				}
			}
		}
		wp_reset_query(); // Resets the query
		return $post_tags;
	}
</code></pre>
<h4>Usage</h4>
<pre><code>get_the_tag_ids('special',',')</code></pre>
<h4>Output <small>(example)</small>:</h4>
<pre><code>8,3,9,8,12</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://threeformed.com/blog/get-page-tag-ids-based-on-a-category-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

