<?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>Keep Walking &#187; Archives</title>
	<atom:link href="http://www.aowaa.com/tag/archives/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.aowaa.com</link>
	<description>Free Wordpress Theme, Make Money Online And Cool Gadgets</description>
	<lastBuildDate>Fri, 10 Jun 2011 14:23:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to Create Archives Page without Any Plugin in WordPress</title>
		<link>http://www.aowaa.com/create-archives-page-without-any-plugin-wordpress/</link>
		<comments>http://www.aowaa.com/create-archives-page-without-any-plugin-wordpress/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 15:30:34 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Archives]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.aowaa.com/?p=220</guid>
		<description><![CDATA[The archives page can show how many articles you have been write, and when you wrote this articles. There are many wordpress plugin that can build your wordpress archives page, such as Clean Archives Reloaded, WP-EasyArchives and so on. If you do not like to use so much wordpress plugin, you can build the archives [...]]]></description>
			<content:encoded><![CDATA[<p>The <strong>archives page</strong> can show how many articles you have been write, and when you wrote this articles. There are many wordpress plugin that can build your wordpress <a href="http://www.aowaa.com/create-archives-page-without-any-plugin-wordpress/" target="_self">archives page</a>, such as <a href="http://www.caxblog.com/wordpress-plugin-clean-archives-reloaded/">Clean Archives Reloaded</a>, <a href="http://www.neoease.com/wp-easyarchives/" target="_blank">WP-EasyArchives</a> and so on.</p>
<p>If you do not like to use so much <a href="../tag/plugin/" target="_self">wordpress plugin</a>, you can build the <strong>archives page</strong> yourself. Do some copy-edit to your <code>page.php</code> file, you can have your own <a href="../tag/archives/" target="_self">archives page</a>.</p>
<p><img class="size-full wp-image-232 alignnone" title="WordPress_archives-1" src="http://www.aowaa.com/wp-content/uploads/2009/09/WordPress_archives-1.jpg" alt="WordPress_archives-1" width="400" height="300" /></p>
<p><span id="more-220"></span>1. Copy you <code>page.php</code> file of your wordpress theme and rename it as <code>archives.php</code>. Add this code to the header of the file before <code>&lt;?php get_header(); ?&gt;</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>?php
<span style="color: #666666; font-style: italic;">/*
Template Name: Archives
*/</span>
?<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span></pre></div></div>

<p>2. Add this code below the function <code>&lt;?php the_content(); ?&gt;</code>, or replace the function as you like.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>?php
<span style="color: #666666; font-style: italic;">// echo archives start</span>
<span style="color: #000088;">$lastpost</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>get_var<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT ID FROM <span style="color: #006699; font-weight: bold;">$wpdb</span>-&amp;gt;posts WHERE post_date &amp;lt;'&quot;</span> <span style="color: #339933;">.</span> current_time<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mysql'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;' AND post_status='publish' AND post_type='post' AND post_password='' ORDER BY post_date DESC LIMIT 1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'hfy_archives_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$lastpost</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
 <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;DELETE FROM <span style="color: #006699; font-weight: bold;">$wpdb</span>-&amp;gt;options WHERE option_name LIKE 'hfy_archives_%'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #666666; font-style: italic;">// Get all of the months that have posts</span>
 <span style="color: #000088;">$monthquery</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts FROM &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>posts <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; WHERE post_date &amp;lt;'&quot;</span> <span style="color: #339933;">.</span> current_time<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mysql'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;' AND post_status='publish' AND post_type='post' AND post_password='' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC&quot;</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$monthresults</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>get_results<span style="color: #009900;">&#40;</span><span style="color: #000088;">$monthquery</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$monthresults</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #666666; font-style: italic;">// Loop through each month</span>
 <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$monthresults</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$monthresult</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #000088;">$thismonth</span>    <span style="color: #339933;">=</span> zeroise<span style="color: #009900;">&#40;</span><span style="color: #000088;">$monthresult</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>month<span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$thisyear</span>    <span style="color: #339933;">=</span> <span style="color: #000088;">$monthresult</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>year<span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">// Get all of the posts for the current month</span>
 <span style="color: #000088;">$postquery</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT ID, post_date, post_title, comment_count FROM &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>posts <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; WHERE post_date LIKE '<span style="color: #006699; font-weight: bold;">$thisyear</span>-<span style="color: #006699; font-weight: bold;">$thismonth</span>-%' AND post_date AND post_status='publish' AND post_type='post' AND post_password='' ORDER BY post_date DESC&quot;</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$postresults</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>get_results<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postquery</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$postresults</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #666666; font-style: italic;">// The month year title things</span>
 <span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'%s %d'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$month</span><span style="color: #009900;">&#91;</span>zeroise<span style="color: #009900;">&#40;</span><span style="color: #000088;">$monthresult</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>month<span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$monthresult</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>year<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$postcount</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$postresults</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&amp;lt;p&amp;gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$text</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;amp;nbsp;(&amp;amp;nbsp;&amp;lt;span&amp;gt;'</span> <span style="color: #339933;">.</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$postresults</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;lt;/span&amp;gt;&amp;amp;nbsp;posts&amp;amp;nbsp;)&amp;lt;/p&amp;gt;'</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&amp;lt;ul class='archiveslist'&amp;gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$postresults</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$postresult</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$postresult</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>post_date <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'0000-00-00 00:00:00'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> get_permalink<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postresult</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>ID<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$arc_title</span>    <span style="color: #339933;">=</span> <span style="color: #000088;">$postresult</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>post_title<span style="color: #339933;">;</span>
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$arc_title</span><span style="color: #009900;">&#41;</span>
 <span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> wptexturize<span style="color: #009900;">&#40;</span><span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arc_title</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #b1b100;">else</span>
 <span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$postresult</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>ID<span style="color: #339933;">;</span>
 <span style="color: #000088;">$title_text</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'read more &amp;amp;quot;'</span> <span style="color: #339933;">.</span> wp_specialchars<span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;amp;quot;'</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'    &amp;lt;li&amp;gt;'</span> <span style="color: #339933;">.</span> mysql2date<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'m-d'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$postresult</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>post_date<span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">':&amp;amp;nbsp;'</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&amp;lt;a href='<span style="color: #006699; font-weight: bold;">$url</span>' title='<span style="color: #006699; font-weight: bold;">$title_text</span>'&amp;gt;<span style="color: #006699; font-weight: bold;">$text</span>&amp;lt;/a&amp;gt;&quot;</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&amp;amp;nbsp;('</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$postresult</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>comment_count <span style="color: #339933;">.</span> <span style="color: #0000ff;">')'</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&amp;lt;/li&amp;gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&amp;lt;/ul&amp;gt;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span>
 update_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'hfy_archives_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$lastpost</span><span style="color: #339933;">,</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
 <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&amp;lt;strong&amp;gt;'</span><span style="color: #339933;">.</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ERROR:'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;lt;/strong&amp;gt; '</span><span style="color: #339933;">.</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'No items were found to be displayed.'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
 <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$output</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//echo archives end</span>
?<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span></pre></div></div>

<p>When you finish this coding, upload the <code>archives.php</code> file to your <a href="http://www.aowaa.com/tag/theme/" target="_self">wordpress theme</a> directory. At this point the archives functions have been created, and you can use it to show your <a href="http://www.aowaa.com/tag/archives/" target="_self">archives</a> posts.</p>
<div id="attachment_233" class="wp-caption aligncenter" style="width: 358px"><img class="size-full wp-image-233 " title="archives-page" src="http://www.aowaa.com/wp-content/uploads/2009/09/archives-page.gif" alt="archives-page" width="348" height="201" /><p class="wp-caption-text">Archives Template</p></div>
<p>Go to the dashboard, create a new page name as <strong>Archives</strong> and select the <strong>Archives</strong> as the page template. Click to see your new page after you publish it. You can see the <a href="http://www.aowaa.com/create-archives-page-without-any-plugin-wordpress/" target="_self">archives page</a> show all your wrote post by post.</p>
<p>The <a href="http://www.aowaa.com/create-archives-page-without-any-plugin-wordpress/" target="_self">archives page</a> can list the articles monthly and show the comment number at the end of each post. The list will update when you post a new articles, so don’t be confused when the list show the wrong comment number.</p>
<hr />
<p><small>© Alex for <a href="http://www.aowaa.com">Keep Walking</a>, 2009. |
<a href="http://www.aowaa.com/create-archives-page-without-any-plugin-wordpress/">Permalink</a> |
<a href="http://www.aowaa.com/create-archives-page-without-any-plugin-wordpress/#comments">2 comments</a> |
Add to
<a href="http://del.icio.us/post?url=http://www.aowaa.com/create-archives-page-without-any-plugin-wordpress/&title=How to Create Archives Page without Any Plugin in WordPress">del.icio.us</a>
<br/>
Post tags: <a href="http://www.aowaa.com/tag/archives/" rel="tag">Archives</a>, <a href="http://www.aowaa.com/tag/hacks/" rel="tag">Hacks</a>, <a href="http://www.aowaa.com/tag/tutorial/" rel="tag">Tutorial</a>, <a href="http://www.aowaa.com/tag/wordpress/" rel="tag">Wordpress</a><br/>
</small></p>]]></content:encoded>
			<wfw:commentRss>http://www.aowaa.com/create-archives-page-without-any-plugin-wordpress/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

