<?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>SEOAdsenseThemes.com &#187; Categories</title>
	<atom:link href="http://www.seoadsensethemes.com/category/wordpress/categories/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.seoadsensethemes.com</link>
	<description>Search Engine Optimized (SEO), Adsense-Ready Free WordPress Themes</description>
	<lastBuildDate>Wed, 25 Aug 2010 06:11:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to list latest posts and subcategories of each top level categories in WordPress</title>
		<link>http://www.seoadsensethemes.com/wordpress-latest-posts-subcategories-each-top-level-categories/</link>
		<comments>http://www.seoadsensethemes.com/wordpress-latest-posts-subcategories-each-top-level-categories/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 15:47:31 +0000</pubDate>
		<dc:creator>Stanley</dc:creator>
				<category><![CDATA[Categories]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[get_categories]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wp_list_categories]]></category>

		<guid isPermaLink="false">http://www.seoadsensethemes.com/?p=4</guid>
		<description><![CDATA[For every top level categories, we'll list the category title, category description, a couple of latest posts in that category and finally list all subcategories.]]></description>
			<content:encoded><![CDATA[<p>Sorry for the long and confusing title. Do allow me to illustrate and describe what I have in mind.</p>
<p>What we&#8217;re going to do here is <span style="text-decoration: underline;">for every top-level categories</span>, we will:</p>
<p><a href="http://www.seoadsensethemes.com/wp-content/uploads/2008/07/custom_wordpress_category_style_06.png"><img class="alignright size-full wp-image-7" title="Sample - Styling and customizing WordPress categories in news and magazine style" src="http://www.seoadsensethemes.com/wp-content/uploads/2008/07/custom_wordpress_category_style_06.png" alt="Sample custom WordPress categories style - Just CSS" width="325" height="443" /></a></p>
<ol>
<li>display the <span style="text-decoration: underline;">category title</span> in bold and the <span style="text-decoration: underline;">category description</span>.</li>
<li>list the <span style="text-decoration: underline;">latest post title</span> prominently displayed as the first entry and <span style="text-decoration: underline;">short excerpt</span>.</li>
<li>list is <span style="text-decoration: underline;">followed by four or five post titles sorted by date</span>.</li>
<li>finally <span style="text-decoration: underline;">all children/subcategories of the category listed at the bottom</span>.</li>
</ol>
<p>Something like what we have here on the right illustration. Using WordPress, I&#8217;ve always wanted to replicate the myriad of ways most news and magazine-style websites present its contents.</p>
<p>If you are familiar with <code>wp_list_categories()</code>, which is the one of main category tags that handles how categories are formatted and displayed, you&#8217;ll realise <code>wp_list_categories()</code> alone is not enough. We&#8217;ll also use <code>get_categories()</code>, <code>get_cat_ID()</code>and a wpdb query direct into WordPress&#8217;s database.</p>
<p>Also, I think the coding in this article is more suited for WordPress themers who prefer to hard-code it into their themes. The solution is a very straightforward sequential code where you can just copy and paste it into your sidebar.php (or wherever you wish) for instance.</p>
<p>Let&#8217;s get down to the source codes &#8230;</p>
<p><span id="more-4"></span><strong>CSS stylesheet</strong></p>
<pre class="syntax-highlight:css">ul.category_list {width:300px; list-style:none; padding:0; margin:0;}
.category_title {background:#333; color:#fff; padding:0.2em 0.5em; font-size:1em; margin:0; text-transform:uppercase;}
.category_box {background:#f8f8f8; border:1px solid #333; border-width:0 1px 1px 1px; margin:0 0 2em 0;}
.category_description {background:#aaa; border-bottom:3px solid #ccc; color:#eee; font-style:italic; display:block; padding:0.5em; font-size:0.9em; font-weight:bold;}
ul.category_posts {list-style:none; margin:0 1em; padding:0; font-size:0.8em;}
ul.category_posts li {border-bottom:1px dotted #bbb; padding:0.75em 0;}
ul.category_posts li.last {border:none; padding:0.5em 0; margin:0 0 1em 0;}
ul.category_posts li a {color:#333;}
ul.category_posts li a.more_articles {text-decoration:underline; font-weight:bold;}
ul.subcategory_list {color:#aaa; padding:1em; margin:0; background:#eee; border-top:1px solid #ccc; font-size:0.8em; font-weight:bold;}
ul.subcategory_list li {display:inline; margin:0 0 0 0.75em;}
ul.subcategory_list li a {color:#333;}
.first_post {font-size:1.2em; font-weight:bold;}
.first_post_excerpt {color:#888; font-weight:normal; font-style:italic;}</pre>
<p><strong>PHP and HTML markup</strong></p>
<pre class="syntax-highlight:php">&lt;?php // get category IDs of Featured, Uncategorized and Personal for exclusion
$categories_to_exclude = get_cat_ID(&#039;featured&#039;).&#039;,&#039;.get_cat_ID(&#039;uncategorized&#039;).&#039;,&#039;.get_cat_ID(&#039;personal&#039;);

// get category IDs for all subcategories (categories where parent is not 0) for exclusion
$subcats = $wpdb-&gt;get_results(&quot;SELECT term_id FROM $wpdb-&gt;term_taxonomy WHERE taxonomy=&#039;Category&#039; AND parent&gt;0&quot;);
foreach ((array)$subcats as $subcat) { $categories_to_exclude .= &#039;,&#039;.$subcat-&gt;term_id; }

// get all categories minus excluded categories
$cats = get_categories(&#039;exclude=&#039;.$categories_to_exclude.&#039;&amp;amp;orderyby=name&amp;amp;hide_empty=0&#039;); ?&gt;

&lt;h3&gt;CATEGORIES&lt;/h3&gt;

&lt;ul class=&quot;category_list&quot;&gt;

&lt;?php foreach ((array)$categories as $category) { ?&gt;
	&lt;li class=&quot;category_box&quot;&gt;&lt;h5 class=&quot;category_title&quot;&gt;• &lt;?php echo $category-&gt;cat_name; ?&gt;&lt;/h5&gt;
			&lt;div class=&quot;category_description&quot;&gt;“&lt;?php echo $category-&gt;category_description; ?&gt;” &lt;/div&gt;

			&lt;?php $the_query = new WP_Query(&#039;cat=&#039;.$category-&gt;cat_ID.&#039;&amp;amp;showposts=5&amp;amp;orderby=post_date&#039;);
			$first = true; ?&gt;

			&lt;ul class=&quot;category_posts&quot;&gt;
			&lt;?php while ($the_query-&gt;have_posts()) : $the_query-&gt;the_post(); ?&gt;

				&lt;?php if ($first) { ?&gt;
					&lt;li class=&quot;first_post&quot;&gt;&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; title=&quot;Permanent Link to &lt;?php the_title(); ?&gt;&quot; &gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;br /&gt;
					&lt;small class=&quot;first_post_excerpt&quot;&gt;&lt;?php echo strip_tags(get_the_excerpt(), &#039;&lt;a&gt;&lt;strong&gt;&#039;); ?&gt;&lt;/small&gt;
				&lt;?php $first = false;
				} else { ?&gt;
					&lt;li&gt;&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; title=&quot;Permanent Link to &lt;?php the_title(); ?&gt;&quot; &gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;
				&lt;?php } ?&gt;
				&lt;/li&gt;
			&lt;?php endwhile; ?&gt;
			&lt;li class=&quot;last&quot;&gt;&lt;a class=&quot;more_articles&quot; href=&quot;&lt;?php the_permalink() ?&gt;&quot; title=&quot;Permanent Link to &lt;?php the_title(); ?&gt;&quot; &gt;More articles in &lt;?php echo $category-&gt;cat_name; ?&gt; »&lt;/a&gt;&lt;/li&gt;
			&lt;/ul&gt;

		&lt;?php $sub_categories =  wp_list_categories(&#039;echo=0&amp;amp;orderby=name&amp;amp;title_li=&amp;amp;hierarchical=0&amp;amp;child_of=&#039;.$category-&gt;cat_ID);
		if ($sub_categories != &quot;&lt;li&gt;No categories&lt;/li&gt;&quot;) { ?&gt;
			&lt;ul class=&quot;subcategory_list&quot;&gt;See Also: &lt;?php echo $sub_categories; ?&gt;&lt;/ul&gt;
		&lt;?php } ?&gt;
	&lt;/li&gt;
&lt;?php } ?&gt;
&lt;/ul&gt;</pre>
<p>I hope you find this short tutorial useful. Thanks for reading!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seoadsensethemes.com/wordpress-latest-posts-subcategories-each-top-level-categories/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
