<?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>Arricc &#187; front page</title>
	<atom:link href="http://www.arricc.net/tag/front-page/feed" rel="self" type="application/rss+xml" />
	<link>http://www.arricc.net</link>
	<description>50% IT snippets that I couldn&#039;t readily find existing help on. 50% drivel.</description>
	<lastBuildDate>Mon, 05 Jul 2010 23:26:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>WordPress Front Page Single Post</title>
		<link>http://www.arricc.net/wordpress-front-page-single-post.php</link>
		<comments>http://www.arricc.net/wordpress-front-page-single-post.php#comments</comments>
		<pubDate>Fri, 11 Sep 2009 13:03:03 +0000</pubDate>
		<dc:creator>Fizzgig</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[front page]]></category>

		<guid isPermaLink="false">http://www.arricc.net/?p=55</guid>
		<description><![CDATA[Well, I&#8217;ve rejigged my site theme, and I decided to play a bit with the layout. The look of the site seemed to be better with just the excerpt from a single post on the front page. Now, that sounds really straight forward and something that WordPress should be able to do out of the [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I&#8217;ve rejigged my site theme, and I decided to play a bit with the layout.</p>
<p>The look of the site seemed to be better with just the excerpt from a single post on the front page.</p>
<p>Now, that sounds really straight forward and something that WordPress should be able to do out of the box. And it is. </p>
<p>However, if you want the &#8220;Older Entries&#8221; pages to then show, say, 10 posts you&#8217;re knackered as all subsequent pages will just show 1 entry. I tried the Custom Post Limits plugin, but it still didn&#8217;t work as page 2 started at post 6.</p>
<p>After reading a lot of entries on this topic (it seems I&#8217;m not the only person keen on this!) and getting nowhere fast. Lots of &#8220;read this link then work it out yourself&#8221; type replies I finally got something to work. Using both the offset AND paging attributes of the query_posts() function!</p>
<p>The only issue with this is that the last page wouldn&#8217;t show at all. This was due to the fact that the front page misses all but 1 of the entries, then the 2nd page starts at entry 2. In effect you&#8217;re missing a number of entries up to the usual number per page minus 1 &#8211; everything that would be on the last page. To get round this, I simply double the number of entries displayed on what WordPress believes is the final page.</p>
<p><span id="more-55"></span></p>
<p>To get this to work, add the following snippit to the top of the home.php file in your theme directory.<br />
If you don&#8217;t have a home.php file then copy your index.php in your theme directory to home.php which will then take precedence according to the <a href="http://codex.wordpress.org/Template_Hierarchy">WordPress Template Heirarcy</a>. I do not recommend adding this to your index.php file.</p>
<p><div class="codeblock"><code><span class="synSpecial">&lt;?php</span><br /><span class="synComment">//WATCH THAT LINE WRAP!</span><br /><span class="synStatement">if</span> <span class="synSpecial">(</span>is_home<span class="synSpecial">())</span> <span class="synSpecial">{</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span class="synStatement">$</span><span class="synIdentifier">page</span> <span class="synStatement">=</span> <span class="synSpecial">(</span>get_query_var<span class="synSpecial">(</span>'<span class="synConstant">paged</span>'<span class="synSpecial">))</span> <span class="synStatement">?</span> get_query_var<span class="synSpecial">(</span>'<span class="synConstant">paged</span>'<span class="synSpecial">)</span> <span class="synStatement">:</span> <span class="synConstant">1</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; <span class="synStatement">if</span> <span class="synSpecial">(</span><span class="synStatement">$</span><span class="synIdentifier">page</span> <span class="synStatement">==</span> <span class="synConstant">1</span><span class="synSpecial">)</span> <span class="synSpecial">{</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; query_posts<span class="synSpecial">(</span>&quot;<span class="synConstant">showposts=1&amp;paged=</span><span class="synStatement">$</span><span class="synIdentifier">page</span>&quot;<span class="synSpecial">)</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; <span class="synSpecial">}</span> <span class="synStatement">else</span> <span class="synSpecial">{</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="synStatement">$</span><span class="synIdentifier">numposts</span> <span class="synStatement">=</span> get_option<span class="synSpecial">(</span>'<span class="synConstant">posts_per_page</span>'<span class="synSpecial">)</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="synComment">//Work out what posts to show first on the page.</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="synStatement">$</span><span class="synIdentifier">offset</span> <span class="synStatement">=</span> <span class="synSpecial">((</span><span class="synStatement">$</span><span class="synIdentifier">page</span> <span class="synConstant">-1</span><span class="synSpecial">)</span> <span class="synStatement">*</span> <span class="synStatement">$</span><span class="synIdentifier">numposts</span><span class="synSpecial">)</span> <span class="synStatement">-</span> <span class="synSpecial">(</span><span class="synStatement">$</span><span class="synIdentifier">numposts</span> <span class="synConstant">-1</span><span class="synSpecial">)</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="synComment">//Quick hack to display double the number of posts on the last page as the offset hides posts per page -1.</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="synStatement">if</span> <span class="synSpecial">(</span><span class="synStatement">$</span><span class="synIdentifier">page</span> <span class="synStatement">==</span> <span class="synStatement">$</span><span class="synIdentifier">wp_query</span><span class="synType">-&gt;</span>max_num_pages<span class="synSpecial">)</span> <span class="synSpecial">{</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="synStatement">$</span><span class="synIdentifier">numposts</span> <span class="synStatement">=</span> <span class="synConstant">2</span><span class="synStatement">*</span> get_option<span class="synSpecial">(</span>'<span class="synConstant">posts_per_page</span>'<span class="synSpecial">)</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="synSpecial">}</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; query_posts<span class="synSpecial">(</span>&quot;<span class="synConstant">offset=</span><span class="synStatement">$</span><span class="synIdentifier">offset</span><span class="synConstant">&amp;paged=</span><span class="synStatement">$</span><span class="synIdentifier">page</span><span class="synConstant">&amp;showposts=</span><span class="synStatement">$</span><span class="synIdentifier">numposts</span>&quot;<span class="synSpecial">)</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; <span class="synSpecial">}</span><br /><span class="synSpecial">}</span><br /><span class="synSpecial">?&gt;</span><br /></code></div></p>
<p class="buymebeer"><form action="https://www.paypal.com/cgi-bin/webscr" target="paypal" method="post"><input type="hidden" name="cmd" value="_xclick" /><input type="hidden" name="business" value="mark@arricc.net" /><input type="hidden" name="return" value="http://www.arricc.net/pp-thanks.php" /><input type="hidden" name="item_name" value="Buy Me a Beer for WordPress Front Page Single Post" /><input type="hidden" name="currency_code" value="GBP" /><input type="hidden" name="amount" value="5" /><input type="image" src="http://www.arricc.net/wp-content/plugins/buy-me-beer/icon_beer.gif" align="left" alt="" title="" hspace="3" /></form><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&amp;business=mark@arricc.net&amp;currency_code=GBP&amp;amount=5&amp;return=http://www.arricc.net/pp-thanks.php&amp;item_name=Buy+Me+a+Beer+for+Wordpress+Front+Page+Single+Post" target="paypal">If you find this article useful, buy me a beer!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.arricc.net/wordpress-front-page-single-post.php/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
