<?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>Webmaster-Source &#187; featured posts</title>
	<atom:link href="https://www.webmaster-source.com/tag/featured-posts/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.webmaster-source.com</link>
	<description>Useful Resources For Webmasters</description>
	<lastBuildDate>Thu, 24 Aug 2017 02:01:18 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.42</generator>
	<item>
		<title>How to Feature Your Best Posts in Your Sidebar</title>
		<link>https://www.webmaster-source.com/2008/01/25/how-to-feature-your-best-posts-in-your-sidebar/</link>
		<comments>https://www.webmaster-source.com/2008/01/25/how-to-feature-your-best-posts-in-your-sidebar/#comments</comments>
		<pubDate>Fri, 25 Jan 2008 15:31:08 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[featured posts]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/2008/01/25/how-to-feature-your-best-posts-in-your-sidebar/</guid>
		<description><![CDATA[Looking for a way to feature some of your better posts? Here&#8217;s a method I&#8217;ve been using for a few months (visible on the index and the screencap to the right). The five most recent posts that I&#8217;ve marked as &#8220;Featured&#8221; will appear in the list, along with a &#8220;view all&#8221; option that takes the [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><img src="http://i27.tinypic.com/fmnfgz.jpg" alt="" hspace="6" vspace="6" width="208" height="152" align="right" />Looking for a way to feature some of your better posts? Here&#8217;s a method I&#8217;ve been using for a few months (visible on the <a href="http://www.webmaster-source.com">index</a> and the screencap to the right).</p>
<p>The five most recent posts that I&#8217;ve marked as &#8220;Featured&#8221; will appear in the list, along with a &#8220;view all&#8221; option that takes the clicker to a <a href="http://www.webmaster-source.com/featured/">custom date-based archive</a>.</p>
<p>How does it work? It&#8217;s done with <a href="http://codex.wordpress.org/The_Loop">multiple loops</a> and categories.<span id="more-386"></span></p>
<h3>Creating the Sidebar List</h3>
<ol>
<li>Create a new category called &#8220;Featured.&#8221; Note its ID (mine is 72, so I&#8217;ll use that throughout this tutorial).</li>
<li>Add a few posts to the category.</li>
<li>Paste the following code into your sidebar, where you want the list to appear.</li>
</ol>
<p><code><br />
&lt;ul&gt;<br />
&lt;?php<br />
$postslist = get_posts('category=<strong>72</strong>&amp;order=DESC&amp;numberposts=5');<br />
foreach ($postslist as $post) :<br />
setup_postdata($post);<br />
?&gt;&lt;li&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/li&gt;&lt;?php<br />
endforeach;<br />
?&gt;<br />
&lt;li&gt;&lt;a href="http://www.webmaster-source.com/featured/"&gt;[View All]&lt;/a&gt;&lt;/li&gt;<br />
&lt;/ul&gt;</code></p>
<p>Be sure to replace the bold &#8220;72&#8221; with the ID of your category. Seeing as this is another loop, the code must be located below your main loop (which means your get_sidebar() command must be below the main loop in your template). If your template&#8217;s sidebar is in the wrong place, you could use the $wpdb-&gt;query() function. However, I will not provide pasteable code, as most themes&#8217; sidebars are below the main loop (and it&#8217;s much better if it is, as your content will be higher up, which is better for search engines).</p>
<h3>Creating a Custom Archive</h3>
<p>Create a new file called featured.php. This will be your template for the archive. Upload it to your theme directory, after adding something like this into it:</p>
<p><code><br />
&lt;?php<br />
/*<br />
Template Name: Featured Posts<br />
*/<br />
?&gt;</code></p>
<p><code><br />
&lt;?php get_header(); ?&gt;<br />
&lt;div id="widecontent"&gt;</code></p>
<p><code>&lt;h2&gt;Featured Posts&lt;/h2&gt;</code></p>
<p><code>&lt;h3&gt;2008&lt;/h3&gt;<br />
&lt;ul&gt;<br />
&lt;?php<br />
query_posts('year=2008&amp;category_name=Featured');<br />
if (have_posts()) :<br />
while (have_posts()) : the_post();<br />
?&gt;&lt;li&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/li&gt;&lt;?php<br />
endwhile;<br />
endif;<br />
?&gt;<br />
&lt;/ul&gt;</code></p>
<p><code>&lt;h3&gt;2007&lt;/h3&gt;<br />
&lt;ul&gt;<br />
&lt;?php<br />
query_posts('year=2007&amp;category_name=Featured');<br />
if (have_posts()) :<br />
while (have_posts()) : the_post();<br />
?&gt;&lt;li&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/li&gt;&lt;?php<br />
endwhile;<br />
endif;<br />
?&gt;<br />
&lt;/ul&gt;</code></p>
<p><code>&lt;/div&gt;<br />
&lt;?php get_sidebar(); ?&gt;<br />
&lt;?php get_footer(); ?&gt;</code></p>
<p>You&#8217;ll have to modify it a little so it will work with your theme. Note that you have to add a loop for every year you have posts (every new year, you need to put a new one in).</p>
<p>Create a new Page (Admin-&gt;Write-&gt;Page) and call it &#8220;Featured Posts&#8221; (or something of the sort). Set the Post Slug to &#8220;featured&#8221; and the Template to &#8220;Featured Posts.&#8221;</p>
<p>Load <em>yourdomain.com/featured/</em> into your browser to make sure everything works.</p>
<p>Note that this isn&#8217;t the only way to create the archive. You could just use the default, at <em>yourdomain.com/category/featured/</em>, or you could use $wpdb-&gt;query() to create a more advanced archive. It&#8217;s up to you, as well as your experience level. $wpdb-&gt;query() is generally the domain of plugin authors, and the large majority of bloggers should probably steer clear.</p>
<p>Well, enjoy your new Featured Posts system.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2008/01/25/how-to-feature-your-best-posts-in-your-sidebar/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/


Served from: www.webmaster-source.com @ 2026-06-08 23:35:06 by W3 Total Cache
-->