<?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>Cozmoslabs &#187; featured posts</title>
	<atom:link href="http://www.cozmoslabs.com/tag/featured-posts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cozmoslabs.com</link>
	<description>Web design and development experiment.</description>
	<lastBuildDate>Thu, 01 Jul 2010 09:26:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Add &#8220;Featured Posts&#8221; to your Thematic child theme</title>
		<link>http://www.cozmoslabs.com/2009/06/26/thematic-featured-posts/</link>
		<comments>http://www.cozmoslabs.com/2009/06/26/thematic-featured-posts/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 13:35:54 +0000</pubDate>
		<dc:creator>Cristian</dc:creator>
				<category><![CDATA[Thematic]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[child theme]]></category>
		<category><![CDATA[featured posts]]></category>

		<guid isPermaLink="false">http://www.cozmoslabs.com/?p=557</guid>
		<description><![CDATA[Featured posts are common in WordPress magazine themes. They let you promote hot topics and bring your best articles right in front of your users. First thing we need to do is create a thematic child theme. This way we won’t make direct changes to Thematic. The featured posts will be inserted on the home [...]


Related posts:<ol><li><a href='http://www.cozmoslabs.com/2009/06/02/street-wordpress-theme/' rel='bookmark' title='Permanent Link: Street WordPress Theme'>Street WordPress Theme</a></li>
<li><a href='http://www.cozmoslabs.com/2010/02/10/exclude-posts-from-wordpress-navigation-in-thematic/' rel='bookmark' title='Permanent Link: Exclude posts from WordPress Navigation in Thematic'>Exclude posts from WordPress Navigation in Thematic</a></li>
<li><a href='http://www.cozmoslabs.com/2008/10/29/installing-wordpress-child-themes-customizing/' rel='bookmark' title='Permanent Link: Installing WordPress Child Themes and Customizing the Byty Theme'>Installing WordPress Child Themes and Customizing the Byty Theme</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div id="attachment_565" class="wp-caption alignright" style="width: 310px"><img src="http://www.cozmoslabs.com/wp-content/uploads/2009/04/featured_posts.jpg" alt="Featured Posts for Thematic" title="featured_posts" width="300" height="200" class="size-full wp-image-565" /><p class="wp-caption-text">Featured Posts for Thematic</p></div>
<p>Featured posts are common in WordPress magazine themes. They let you promote hot topics and bring your best articles right in front of your users. </p>
<p>First thing we need to do is create a <a href="http://www.cozmoslabs.com/2008/09/07/use-wordpress-as-a-cms-with-thematic-part1/">thematic child theme</a>. This way we won’t make direct changes to <a href="http://themeshaper.com/thematic/">Thematic</a>.</p>
<p>The featured posts will be inserted on the home page before the rest of the articles. We&#8217;ll display the latest 3 posts which are tagged &#8216;featured&#8217;. </p>
<p class="preview_download"><a href="http://www.cozmoslabs.com/projects/wp/?theme=featured" target="_blank"><img src="http://www.cozmoslabs.com/wp-content/plugins/download-monitor/img/preview.gif" border="0" alt="preview thematic child theme" /></a></p>
<p><span id="more-557"></span></p>
<p>We now have to add the code inside of functions.php file of your child theme (don&#8217;t forget the <em><&#63;php</em> opening tag and the <em>&#63;></em> ending tag).</p>
<pre class="brush: php;">
function featured_posts(){

		$my_query = new WP_Query('tag=featured&amp;showposts=3');

		echo '&lt;ul id=&quot;featured-posts&quot;&gt;';
		$feat_class = array();

		while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post();
				$feat_class = array();
				// Category for the post queried
				foreach ( (array) get_the_category() as $cat )
					$feat_class[] = 'category-' . $cat-&gt;slug;
					$feat_class = join(&quot; &quot;, $feat_class);
				?&gt;
				&lt;li id=&quot;featured-&lt;?php the_ID(); ?&gt;&quot; class=&quot;&lt;?php echo $feat_class; ?&gt;&quot;&gt;
					&lt;?php
						$posttitle = '&lt;h4&gt;&lt;a href=&quot;';
						$posttitle .= get_permalink();
						$posttitle .= '&quot; title=&quot;';
						$posttitle .= __('Permalink to ', 'thematic') . the_title_attribute('echo=0');
						$posttitle .= '&quot; rel=&quot;bookmark&quot;&gt;';
						$posttitle .= get_the_title();
						$posttitle .= &quot;&lt;/a&gt;&lt;/h4&gt;\n&quot;;
						echo $posttitle;

						the_excerpt();
					?&gt;

				&lt;/li&gt;&lt;!-- .post --&gt;
		&lt;?php
		endwhile;
		echo '&lt;/ul&gt;';
}
add_action('thematic_above_indexloop','featured_posts');
</pre>
<p>The first line <em>$my_query = new WP_Query(&#8216;tag=featured&#038;showposts=3&#8242;);</em> defines the name of the tag that targets your posts (you can have any tag name there) and the number of featured articles (three in this case).</p>
<p>Right now it&#8217;s just a list of posts so a bit of css styling is in order to make it look attractive to your visitors. Add this css to your style.css file inside the Child Theme.</p>
<pre class="brush: css;">
ul#featured-posts {
    float: left;
    margin: 0;
    padding: 0 0 15px 0;
    list-style: none;
    color: #111;
    font-size: 11px;
    line-height:14px;
    font-family: Helvetica, Arial, sans-serif;
}
#featured-posts li {
    float: left;
    width: 135px;
    padding: 12px 10px 10px 10px;
    margin-right: 15px;
    min-height: 260px;
    background:#f1f1f1;
    border:3px double #ccc;
}

#featured-posts li p {
    margin: 0;
    padding: 0;
}

#featured-posts li:hover {
    background:#fff;
}
#featured-posts li h4 a {
    font-family:Georgia, Times, sans-serif;
    font-size: 12px;
    line-height: 13px;
    display: block;
    padding: 5px 1px;
    color: #111;
    font-weight: bold;
}
</pre>
<p>I hope you find it useful and don&#8217;t hesitate to post in the comments were you&#8217;ve used this.</p>


<p>Related posts:<ol><li><a href='http://www.cozmoslabs.com/2009/06/02/street-wordpress-theme/' rel='bookmark' title='Permanent Link: Street WordPress Theme'>Street WordPress Theme</a></li>
<li><a href='http://www.cozmoslabs.com/2010/02/10/exclude-posts-from-wordpress-navigation-in-thematic/' rel='bookmark' title='Permanent Link: Exclude posts from WordPress Navigation in Thematic'>Exclude posts from WordPress Navigation in Thematic</a></li>
<li><a href='http://www.cozmoslabs.com/2008/10/29/installing-wordpress-child-themes-customizing/' rel='bookmark' title='Permanent Link: Installing WordPress Child Themes and Customizing the Byty Theme'>Installing WordPress Child Themes and Customizing the Byty Theme</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.cozmoslabs.com/2009/06/26/thematic-featured-posts/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Database Caching 19/56 queries in 0.055 seconds using disk

Served from: www.cozmoslabs.com @ 2010-07-31 02:23:55 -->