<?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/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>I&#039;d Rather Be Writing &#187; loop</title>
	<atom:link href="http://idratherbewriting.com/tag/loop/feed/" rel="self" type="application/rss+xml" />
	<link>http://idratherbewriting.com</link>
	<description>The Latest Trends in Technical Communication</description>
	<lastBuildDate>Fri, 10 Feb 2012 23:59:59 +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>WordPress Tip: Show the Latest Post in Full, Then Summaries of the Other Posts</title>
		<link>http://idratherbewriting.com/2008/07/31/wordpress-tip-show-the-latest-post-in-full-then-summaries-of-the-other-posts/</link>
		<comments>http://idratherbewriting.com/2008/07/31/wordpress-tip-show-the-latest-post-in-full-then-summaries-of-the-other-posts/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 07:39:17 +0000</pubDate>
		<dc:creator>Tom Johnson</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[dooce]]></category>
		<category><![CDATA[jane]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[tricks]]></category>
		<category><![CDATA[Typepad]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Newsletter]]></category>

		<guid isPermaLink="false">http://www.idratherbewriting.com/?p=1751</guid>
		<description><![CDATA[Jane has wanted to implement something like Dooce&#8217;s Daily Chuck, where a new picture appears every day somewhere on the blog but not in the feed. The picture is usually just that &#8212; a picture, without much else. It works well to draw people to your site each day, knowing that you have something new. For the past two weeks I&#8217;ve been trying to figure ... <a href="http://idratherbewriting.com/2008/07/31/wordpress-tip-show-the-latest-post-in-full-then-summaries-of-the-other-posts/">more &#187;</a>]]></description>
			<content:encoded><![CDATA[<p>Jane has wanted to implement something like Dooce&#8217;s Daily Chuck, where a new picture appears every day somewhere on the blog but not in the feed. The picture is usually just that &#8212; a picture, without much else. It works well to draw people to your site each day, knowing that you have something new.</p>
<p>For the past two weeks I&#8217;ve been trying to figure this out without much success. But I did come pretty close to achieving it. <a href="http://www.whataboutmomblog.com/category/daily/" target="_blank">See the final effect here.</a> And if you&#8217;re interested in the how-to, keep reading.</p>
<p><span id="more-1751"></span></p>
<p>First, to get a better idea of how Dooce&#8217;s Daily Chuck works, <a href="http://dooce.com/" target="_blank">go to her site</a> and click the dog picture in the banner. It opens to a large image of the dog (&#8220;Chuck&#8221;), and you can click the Previous or Next links to navigate to the photos for the other days.</p>
<div id="attachment_1756" class="wp-caption aligncenter" style="width: 509px"><a href="http://www.idratherbewriting.com/wp-content/uploads/2008/07/dailychukck.png"><img src="http://www.idratherbewriting.com/wp-content/uploads/2008/07/dailychukck.png" alt="Dooce&#039;s Daily Chuck" title="Daily Chuck" width="499" height="108" class="size-full wp-image-1756" /></a><p class="wp-caption-text">Dooce's Daily Chuck</p></div>
<p>(By the way, I <a href="http://www.whataboutmomblog.com/2008/06/07/in-which-i-meet-an-icon-dooce-is-about-what-youd-expect-as-is-her-book/" target="_blank">once met Heather</a> at a book signing in SLC.)</p>
<p>Dooce is on <a href="http://typepad.com">Typepad</a>, which may have some tricks that <a href="http://wordpress.org">WordPress</a> doesn&#8217;t. The easiest way to accomplish this same effect in WordPress is through the <a href="http://www.alakhnor.com/post-thumb" target="_blank">Post-Thumb plugin</a>. (If you&#8217;re using Firefox 3, you may see a &#8220;Reported Attack Site!&#8221; message when going to the Post-Thumb plugin page. Instead, open the site in IE or go to the plugin&#8217;s page on <a href="http://wordpress.org/extend/plugins/alakhnors-post-thumb/" target="_blank">WordPress</a>.)</p>
<p>The Post-Thumb plugin scans your latest posts (of a specific category, if you want) and pulls out a thumbnail of the image with a link to the actual post. Perfect, right?</p>
<p>So I implemented it on Jane&#8217;s blog tonight and &#8230; down it went. I assume the Post-Thumb plugin initiated an intensive series of MySQL queries that triggered BlueHost&#8217;s extremely sensitive CPU Exceeded Error messages, and the site was down for a good 20 minutes.</p>
<div id="attachment_1752" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.idratherbewriting.com/wp-content/uploads/2008/07/cpuquote.png"><img src="http://www.idratherbewriting.com/wp-content/uploads/2008/07/cpuquote.png" alt="CPU Exceeded Errors -- from BlueHost" title="CPU Exceeded Errors -- from BlueHost" width="500" height="225" class="size-full wp-image-1752" /></a><p class="wp-caption-text">CPU Exceeded Errors -- from BlueHost</p></div>
<p>By the way, the <a href="http://wordpress.org/extend/plugins/wp-super-cache/" target="_blank">wp-supercache plugin</a> seems to somewhat cure the CPU Exceeded Error messages, but I still think BlueHost has an abnormal amount of these error messages. If you google <a href="http://www.google.com/search?hl=en&amp;client=firefox-a&amp;rls=org.mozilla%3Aen-US%3Aofficial&amp;hs=LR7&amp;q=cpu+quota&amp;btnG=Search" target="_blank">CPU Quota</a>, most of the sites mention BlueHost. So perhaps the Post-Thumb plugin will work fine for you on a different host. If so, great.</p>
<p>There is, of course, more than one way to skin a cat. I&#8217;m still working on the way to show the latest thumbnail image in an RSS feed, but in the meantime, I found a neat little query script for the WordPress loop that shows the latest post in full, and then shows just the titles of posts after that.</p>
<p>The WordPress loop is the PHP script that calls the latest posts from the MySQL database. (<a href="http://codex.wordpress.org/The_Loop" target="_blank">Read more about the WordPress loop here</a>.) The loop accepts various queries before it that control how the posts appear. <a href="http://codex.wordpress.org/Template_Tags/query_posts" target="_blank">(Read more about post queries here</a>.)</p>
<p>Here&#8217;s the script (which I <a href="http://wordpress.org/support/topic/177123" target="_blank">found here</a> searching the WordPress support forums).</p>
<blockquote><p>&lt;?php if (have_posts()) : ?&gt;<br />
&lt;?php $count = 0; ?&gt;</p>
<p>&lt;?php while (have_posts()) : the_post(); ?&gt;<br />
&lt;?php $count++; ?&gt;</p>
<p>&lt;?php if ($count &lt;= 2) : ?&gt;</p>
<p>&lt;h2&gt;&lt;a class=&#8221;permalink&#8221; href=&#8221;&lt;?php the_permalink() ?&gt;&#8221; rel=&#8221;bookmark&#8221; title=&#8221;Permanent Link to &lt;?php the_title(); ?&gt;&#8221;&gt;<br />
&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt;</p>
<p>&lt;?php the_content(); ?&gt; // display the full content of the first two posts only</p>
<p>&lt;?php else : ?&gt;</p>
<p>&lt;h2&gt;&lt;a class=&#8221;permalink&#8221; href=&#8221;&lt;?php the_permalink() ?&gt;&#8221; rel=&#8221;bookmark&#8221; title=&#8221;Permanent Link to &lt;?php the_title(); ?&gt;&#8221;&gt;       &lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt;  // Just the permalinks</p>
<p>&lt;?php endif; ?&gt;<br />
&lt;?php endwhile; ?&gt;<br />
&lt;?php else : ?&gt;<br />
&lt;?php endif; ?&gt;</p></blockquote>
<p>You have to massage the styles to fit your blog a bit.</p>
<p>The <a href="http://gluedideas.com/" target="_blank">Subtle WordPress Theme</a> has a similar feature hard-baked into the home page. But Jane didn&#8217;t want her home page like this, just a specific category.</p>
<p><em>Oh man, this is getting more complicated than I wanted to get into here. I was going for a 10 minute post, but &#8230;.</em></p>
<p>Jane wanted just one category to show the latest post like this. So I copied the category.php code into a text editor (Notepad ++), and then swapped the category&#8217;s loop with the above modified loop, and then inserted the styles of her theme to match. Here&#8217;s the resulting category code:</p>
<blockquote><p>
&lt;?php if (have_posts()) : ?&gt;<br />
&lt;?php $count = 0; ?&gt;</p>
<p>&lt;?php while (have_posts()) : the_post(); ?&gt;<br />
&lt;?php $count++; ?&gt;</p>
<p>&lt;?php if ($count &lt;= 1) : ?&gt;</p>
<p>&lt;h3&gt;&lt;a class=&#8221;permalink&#8221; href=&#8221;&lt;?php the_permalink() ?&gt;&#8221; rel=&#8221;bookmark&#8221; title=&#8221;Permanent Link to &lt;?php the_title(); ?&gt;&#8221;&gt;<br />
&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h3&gt; &lt;div style=&#8221;margin-top:-2px;&#8221;&gt;&lt;small&gt;&lt;?php the_time(&#8216;m.d.y&#8217;); ?&gt; &lt;b&gt;|&lt;/b&gt; &lt;?php the_category(&#8216;, &#8216;) ?&gt; | &lt;?php comments_number(&#8216;Comment?&#8217;, &#8217;1 Comment&#8217;, &#8216;% Comments&#8217; ) ?&gt; &lt;/small&gt;&lt;/div&gt;&lt;br/&gt; </p>
<p>&lt;?php the_content(); ?&gt; </p>
<p>&lt;b style=&#8221;size:2em;border-bottom: 1px solid black;&#8221;&gt;Previous Entries&lt;/b&gt;<br />
&lt;?php else : ?&gt;<br />
&lt;h5&gt;&lt;a class=&#8221;permalink&#8221; href=&#8221;&lt;?php the_permalink() ?&gt;&#8221; rel=&#8221;bookmark&#8221; title=&#8221;Permanent Link to &lt;?php the_title(); ?&gt;&#8221;&gt;       &lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h5&gt; </p>
<p>&lt;?php endif; ?&gt;</p>
<p>&lt;?php endwhile; ?&gt;</p>
<p>&lt;?php else : ?&gt;</p>
<p>&lt;?php endif; ?&gt;
</p></blockquote>
<p>I then saved it as a new file, titling it category-87.php. Why category-87? Because when WordPress serves up a category view, it first looks for category templates for the specific category. If a category template exists, it uses that template rather than the regular category.php template. In this case, category 87 is ID for the Daily Dick and Jane category.</p>
<p>(By the way, to find the category ID, go to Manage &gt; Categories. Move your mouse over the category title and look at the numbers at the far right of the string in the task bar. Nice, huh?)</p>
<p>I also needed to exclude category 87 from the home page. To do so, I added this query post code before the loop in the index.php file.</p>
<blockquote><p>
&lt;?php<br />
if (is_home()) {<br />
query_posts(&#8220;cat=-87&#8243;);<br />
}<br />
?&gt;
</p></blockquote>
<p>Now all posts in category 87 are excluded from the home page, but not the feed. I use Feedburner, so I just edited the feed details in Feedburner to exclude category 87.</p>
<p>I just changed the feed from</p>
<blockquote><p>http://whataboutmomblog.com/wp-rss2.php</p></blockquote>
<p>to the following:</p>
<blockquote><p>http://whataboutmomblog.com/wp-rss2.php?cat=-87</p></blockquote>
<p>And then I added some style to the h5 tag that wraps the previous titles.</p>
<p>Check it out by going to Jane&#8217;s blog and clicking <a href="http://whataboutmomblog.com/category/daily" target="_blank">Daily Dick and Jane</a>. By the way, did you notice that she has 600 comments on <a href="http://www.whataboutmomblog.com/2008/07/25/things-that-must-go-from-the-ridiculous-to-the-sublime-also-free-undies-a-50-hanes-giveaway/" target="_blank">her underwear giveaway post</a>?</p>
]]></content:encoded>
			<wfw:commentRss>http://idratherbewriting.com/2008/07/31/wordpress-tip-show-the-latest-post-in-full-then-summaries-of-the-other-posts/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
	</channel>
</rss>

