<?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>gHacks technology news &#187; categories</title>
	<atom:link href="http://www.ghacks.net/tag/categories/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ghacks.net</link>
	<description>A technology blog covering software, mobile phones, gadgets, security, the Internet and other relevant areas.</description>
	<lastBuildDate>Wed, 25 Nov 2009 11:56:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to show 5 top categories in Wordpress</title>
		<link>http://www.ghacks.net/2009/04/09/how-to-show-5-top-categories-in-wordpress/</link>
		<comments>http://www.ghacks.net/2009/04/09/how-to-show-5-top-categories-in-wordpress/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 10:02:44 +0000</pubDate>
		<dc:creator>Daniel Pataki</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[categories]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.ghacks.net/?p=11827</guid>
		<description><![CDATA[Wordpress is a great piece of software, and allows more than you&#8217;d think to be done with simple coding. I bet that a lot of people out there would look for a plugin to do this, but your top five categories can very easily be shown using a Wordpress template tag, just a half a [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.ghacks.net/wp-content/uploads/2009/04/wordpress.png" alt="wordpress" title="wordpress" width="128" height="128" class="alignleft size-full wp-image-11834" />Wordpress is a great piece of software, and allows more than you&#8217;d think to be done with simple coding. I bet that a lot of people out there would look for a plugin to do this, but your top five categories can very easily be shown using a Wordpress template tag, just a half a line of code.</p>
<p>The tag we need is called &#8220;wp_list_categories()&#8221; and by default it lists all your categories in alphabetical order. All we need to do is add some arguments to it to modify the default values and we&#8217;re done! We need to limit the number of items shown to five, we also want to show the post counts in the categories and we want to order the list by the post count, in descending order.</p>
<p>The &#8220;number&#8221; argument actually has no default value. The reason for this is that it limits the SQL query directly, so there is no need for it by default. We can add it though to impose a limit, so our first argument will be &#8220;number=5&#8243;. We also want to show the post counts, so we use &#8220;show_count=1&#8243; to enable this (show_count=0 is the default).</p>
<p><span id="more-11827"></span>We also want to order the list by the post count, so we use &#8220;orderby=count&#8221; to achieve this. By default lists are sorted ascending, meaning that the lowest post count would show up first. To make the list descending, we can use &#8220;order=DESC&#8221;.</p>
<p>I also use one last argument in there, which is &#8220;title_li=&#8221;. This sets the title of the list to be nothing, by default the list is presented with a title. I like to hard code my titles for a few reasons, but feel free to change this as you like. So here is the complete code I used, one simple line to do a seemingly hard task, enjoy</p>
<p>&lt;?php wp_list_categories(&#8217;number=5&amp;show_count=1&amp;orderby=count&amp;order=DESC&amp;title_li=&#8217;) ?&gt;</p>
<p><img class="alignleft size-full wp-image-10878" src="http://www.ghacks.net/wp-content/uploads/2009/03/scrip_twitter.gif" alt="Script" width="53" height="53" /><strong>If you&#8217;d like to read some similar articles, take a look at <a title="Web development blog" href="http://scriptastique.com">Scriptastique</a>, a blog all about web development and coding, with great tips on CSS, HTML, PHP, MySQL and Javascript and tutorials and screencasts coming soon! You can follow us on our <a title="Scriptastique RSS feed" href="http://feeds2.feedburner.com/scriptastique">RSS feed</a>, or <a title="Scriptastique on Twitter" href="http://twitter.com/scriptastique">Twitter</a> where we&#8217;re posting 3-4 short tips daily now!</strong></p>

	Tags: <a href="http://www.ghacks.net/tag/blog/" title="blog" rel="tag">blog</a>, <a href="http://www.ghacks.net/tag/categories/" title="categories" rel="tag">categories</a>, <a href="http://www.ghacks.net/tag/php/" title="php" rel="tag">php</a>, <a href="http://www.ghacks.net/tag/web-development/" title="web development" rel="tag">web development</a>, <a href="http://www.ghacks.net/tag/wordpress/" title="wordpress" rel="tag">wordpress</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.ghacks.net/2009/04/08/wordpress-blogs-create-custom-tag-pages/" title="Wordpress Blogs: Create Custom Tag Pages (April 8, 2009)">Wordpress Blogs: Create Custom Tag Pages</a> (5)</li>
	<li><a href="http://www.ghacks.net/2008/08/05/zoundry-raven-portable-blog-editor/" title="Zoundry Raven portable Blog Editor (August 5, 2008)">Zoundry Raven portable Blog Editor</a> (6)</li>
	<li><a href="http://www.ghacks.net/2009/02/02/wordpress-your-attempt-to-edit-this-post-has-failed/" title="Wordpress: Your attempt to edit this post has failed (February 2, 2009)">Wordpress: Your attempt to edit this post has failed</a> (8)</li>
	<li><a href="http://www.ghacks.net/2009/03/29/wordpress-template-tags-you-should-know/" title="Wordpress template tags you should know (March 29, 2009)">Wordpress template tags you should know</a> (4)</li>
	<li><a href="http://www.ghacks.net/2009/08/11/wordpress-remote-admin-password-reset-vulnerability/" title="Wordpress Remote Admin Password Reset Vulnerability (August 11, 2009)">Wordpress Remote Admin Password Reset Vulnerability</a> (13)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.ghacks.net/2009/04/09/how-to-show-5-top-categories-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
