<?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>Will Hanke &#187; hacks</title>
	<atom:link href="http://www.willhanke.com/tag/hacks/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.willhanke.com</link>
	<description>Saint Louis MO Search Engine Marketing and Optimization</description>
	<lastBuildDate>Wed, 08 Feb 2012 19:20:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Showing Latest Post on Static (non-WordPress) Page</title>
		<link>http://www.willhanke.com/2009/10/18/show-latest-post-static-page/</link>
		<comments>http://www.willhanke.com/2009/10/18/show-latest-post-static-page/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 15:55:17 +0000</pubDate>
		<dc:creator>Will</dc:creator>
				<category><![CDATA[helpful scripts]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.willhanke.com/?p=704</guid>
		<description><![CDATA[I&#8217;ve got a client who has a very nice website which was built quite a while back.  Since launching, they wanted to add a blog and a few other things to their site, for which we used WordPress.  Also along the way, they wanted to show their most recent post on their home page, which [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve got a client who has a very nice website which was built quite a while back.  Since launching, they wanted to add a blog and a few other things to their site, for which we used WordPress.  Also along the way, they wanted to show their most recent post on their home page, which is outside of &#8220;the loop&#8221; for WordPress.</p>
<p>Now I&#8217;ve never claimed to be a WP pro, but I have figured out how to make this work.  Below is the code to get it done.  The trick is the first line, the required <strong>wp-load</strong> file.  That&#8217;s what lets you use some of the wp functions outside of the loop.</p>
<p style="padding-left: 30px;"><code>&lt;?php require( 'path_to_blog_root/wp-load.php' );<br />
$getpostq=mysql_query('SELECT ID,post_title FROM wp_posts WHERE post_status="publish" ORDER BY post_date DESC LIMIT 1');<br />
if (!$getpostq) { die('Error selecting info: '.mysql_error()); }<br />
while ($getpostr=mysql_fetch_array($getpostq)) {<br />
$post_title=$getpostr['post_title'];<br />
$pid= $getpostr['ID'];<br />
$postlink=get_permalink($pid);<br />
echo "Recent Discussion: &lt;a href=\"$postlink\" title=\"Link to $post_title\"&gt;$post_title&lt;/a&gt;";</code></p>
<p>If you also want the post date, you can add these lines:</p>
<p style="padding-left: 30px;"><code>&lt;?php require( 'path_to_blog_root/wp-load.php' );<br />
$getpostq=mysql_query('SELECT ID,post_title FROM wp_posts WHERE post_status="publish" ORDER BY post_date DESC LIMIT 1');<br />
if (!$getpostq) { die('Error selecting info: '.mysql_error()); }<br />
while ($getpostr=mysql_fetch_array($getpostq)) {<br />
$post_date=$getpostr['post_date'];<br />
$post_date=date('F j, Y', strtotime($post_date));<br />
$post_title=$getpostr['post_title'];<br />
$pid= $getpostr['ID'];<br />
$postlink=get_permalink($pid);<br />
echo "Recent Discussion: &lt;a href=\"$postlink\" title=\"Link to $post_title\"&gt;$post_title&lt;/a&gt;%lt;i&gt;($post_date)&lt;/i&gt;"; ?&gt;</code></p>
<p>By the way, if you have a better way to do this, I&#8217;d love to see it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.willhanke.com/2009/10/18/show-latest-post-static-page/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

