<?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>Dev4Press&#187; genre Tag Archives,  | Dev4Press</title> <atom:link href="http://www.dev4press.com/tag/genre/feed/" rel="self" type="application/rss+xml" /><link>http://www.dev4press.com</link> <description>Premium Plugins and Themes for WordPress</description> <lastBuildDate>Thu, 09 Feb 2012 20:24:04 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Using Custom Taxonomies</title><link>http://www.dev4press.com/2009/tutorials/wordpress/tips/using-custom-taxonomies/</link> <comments>http://www.dev4press.com/2009/tutorials/wordpress/tips/using-custom-taxonomies/#comments</comments> <pubDate>Tue, 28 Jul 2009 01:43:41 +0000</pubDate> <dc:creator>MillaN</dc:creator> <category><![CDATA[Tips]]></category> <category><![CDATA[Blog]]></category> <category><![CDATA[buggy]]></category> <category><![CDATA[director name]]></category> <category><![CDATA[example]]></category> <category><![CDATA[genre]]></category> <category><![CDATA[good solution]]></category> <category><![CDATA[hierarchy]]></category> <category><![CDATA[minor revisions]]></category> <category><![CDATA[movie genres]]></category> <category><![CDATA[query]]></category> <category><![CDATA[rewrite]]></category> <category><![CDATA[several movies]]></category> <category><![CDATA[taxonomies]]></category> <category><![CDATA[taxonomy]]></category><guid
isPermaLink="false">http://www.dev4press.com/?p=568</guid> <description><![CDATA[With WordPress 2.8 we got another interesting feature called custom taxonomies. You can make taxonomies from anything you want and use them much like you already use tags and categories. Unfortunately, themes offer only partial support (unsolvable problem) for custom taxonomies, but it's not that complicated to implement.<br
/><div><img
src="http://www.dev4press.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>5</strong> (0 votes cast)</div><br
/><a
target="_blank" href="http://www.gdstarrating.com/"><img
src="http://cdnx.dev4press.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br
/>]]></description> <content:encoded><![CDATA[<p>With WordPress 2.8 we got another interesting feature called custom taxonomies. You can make taxonomies from anything you want and use them much like you already use tags and categories. Unfortunately, themes offer only partial support (unsolvable problem) for custom taxonomies, but it&#8217;s not that complicated to implement.</p><p><span
id="more-568"></span></p><p>When the first custom taxonomies were announced I wasn&#8217;t a big fan of the idea. Also, in the beginning custom taxonomies were very buggy, and hard to test. But, fortunately that&#8217;s now changed, and with 2 minor revisions it looks very stable. I have been interested in the way all that works, but I didn&#8217;t had a real chance to use custom taxonomies.</p><p>But now, I am working on new website, and using custom taxonomies came so natural and easy that I changed things a bit so I can use more of them for different types of data. Before I proceed on actual example on how to use it, I will try to explain exactly what you get bu using custom taxonomies.</p><p>As you know tags are widely used and very important on Â any blog. But, tags are too wide and anything can be a tag. It&#8217;s not that specific as you might need. Same problem is with categories. In many cases you will need to add more specific, more targeted version of tags or even categories. Custom taxonomies can help you do just that. Let&#8217;s say that you want to make a website about movies. And you need to have a posts about movies. First thing you might wanna do is to make categories with movie genres. But that&#8217;s not that good solution when you have movies belonging to more than one genre. Also, you might wanna use categories for some more things. So, you create a custom taxonomy for genre. Similar will be with actors and directors. What&#8217;s the biggest benefit from this? If you have a lot of movies, you will have several movies directed by the same director. You can query all posts based on the director name and get all movies directed by him. Same goes for actors, and genres. Since archives template in theme already handles tags and categories, it will do just fine with custom taxonomies and you can easily get the archive page with post from a director or belonging to specific genre.</p><p>So, here is how to add these 3 custom taxonomies. You can do this from theme or plugin, all the same. If you use theme method, most logical location is functions.php.</p><pre class="brush: php; title: ; notranslate">
add_action('init', 'init_taxonomies');

function init_taxonomies() {
register_taxonomy('genres', 'post', array('hierarchical' =&gt; false, 'label' =&gt; 'Genres', 'query_var' =&gt; true, 'rewrite' =&gt; true));
register_taxonomy('actors', 'post', array('hierarchical' =&gt; false, 'label' =&gt; 'Actors', 'query_var' =&gt; true, 'rewrite' =&gt; true));
register_taxonomy('directors', 'post', array('hierarchical' =&gt; false, 'label' =&gt; 'Directors', 'query_var' =&gt; true, 'rewrite' =&gt; true));
}
</pre><div
id="attachment_573" class="wp-caption alignright" style="width: 203px"><a
title="Taxonomies Widgets" rel="lightbox" href="http://cdnx.dev4press.com/wp-content/uploads/2009/07/taxonomies_postedit.png"><img
class="size-medium wp-image-573" title="Taxonomies Widgets" src="http://cdnx.dev4press.com/wp-content/uploads/2009/07/taxonomies_postedit-275x300.png" alt="Taxonomies Widgets" width="193" height="210" /></a><p
class="wp-caption-text">Taxonomies Widgets</p></div><p>This will ensure that Post menu will be expanded to include all custom taxonomies you added, and that post edit page widgets for each one is added. You can see the two widgets on the image on the right. As you can see there are many parameters for adding taxonomy. First you give taxonomy short name (no spaces or special characters), and then you have array with settings. Hierarchical will be used to create new taxonomy to look like tags or like categories that support hierarchy. Label is the name used in menus or widgets. Query_var and Rewrite will add taxonomy to WP_Query object and to rewriter, and I suggest leaving that active.</p><p>Post menu will be expanded with new panel for each taxonomy, and this panel looks like tags or categories panel, and works the same.</p><p>Out of the box new archives URL&#8217;s should be working also, so you can use url like this one:</p><blockquote><p>http://www.website.com/actors/ben-browder/</p></blockquote><p>And you will get all posts that have actors taxonomy Ben Browder. This will get all movies that this actor starred in. Simple as that. The same way WP_Query gets new variable for each of the taxonomies you can also use, or to get tag cloud. Here are few examples:</p><pre class="brush: php; title: ; notranslate">
get_the_term_list($post-&gt;ID, 'actors', 'Actors: ', ', ', '' );
wp_tag_cloud(array('taxonomy' =&gt; 'actors', 'number' =&gt; 20));
query_posts(array('actors' =&gt; 'ben-browder'));
</pre><p>First will get you list similar to tags list for the post in the theme, second render widget-like tag cloud, and the third one is example of query_posts functions, and will pull posts for Ben Browder.</p><p>And for the end of the post, here is the list of some useful URL&#8217;s:</p><blockquote><p><a
href="http://codex.wordpress.org/Function_Reference/register_taxonomy" target="_blank">http://codex.wordpress.org/Function_Reference/register_taxonomy</a><br
/> <a
href="http://codex.wordpress.org/Function_Reference" target="_blank">http://codex.wordpress.org/Function_Reference</a></p></blockquote><p>The easiest way to work with taxonomies is to use our GD Taxonomies Tools plugin:</p><blockquote><p><a
href="http://www.dev4press.com/plugins/gd-taxonomies-tools/">http://www.dev4press.com/plugins/gd-taxonomies-tools/</a></p></blockquote><script src="http://feeds.feedburner.com/~s/adsense@gdragon.info?i=http://www.dev4press.com/2009/tutorials/wordpress/tips/using-custom-taxonomies/" type="text/javascript" charset="utf-8"></script><br
/><div><img
src="http://www.dev4press.com/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>5</strong> (0 votes cast)</div><br
/><a
target="_blank" href="http://www.gdstarrating.com/"><img
src="http://cdnx.dev4press.com/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br
/>]]></content:encoded> <wfw:commentRss>http://www.dev4press.com/2009/tutorials/wordpress/tips/using-custom-taxonomies/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)
Content Delivery Network via cdnx.dev4press.com

Served from: www.dev4press.com @ 2012-02-09 22:43:42 -->
