<?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>ElegantWebDesigns &#124; Photographers &#38; Artists WordPress Themes, Web Design, PSD Album Templates &#187; WP Tips &amp; Tricks</title>
	<atom:link href="http://www.elegantwebdesigns.net/category/wp-tips-tricks/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.elegantwebdesigns.net</link>
	<description>Your one stop for all your online presence needs. Specialized in Photographers &#38; Artists Websites. Word Press templates, Custom Web Designs, E-Commerce Websites.</description>
	<lastBuildDate>Wed, 11 Jan 2012 14:49:08 +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>Show ONLY WP Recent Published Posts</title>
		<link>http://www.elegantwebdesigns.net/2010/06/show-only-wp-recent-published-posts/</link>
		<comments>http://www.elegantwebdesigns.net/2010/06/show-only-wp-recent-published-posts/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 14:01:57 +0000</pubDate>
		<dc:creator>Editorial Staff</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[WP Tips & Tricks]]></category>
		<category><![CDATA[recent posts]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.elegantwebdesigns.net/?p=263</guid>
		<description><![CDATA[One of the key features of  WordPress is the ability to do basically anything with it. By just adding a little piece of code to the functions.php, to any of the pages, sidebar or to both many things can be achieved. Lately adding a list of recent posts to a blog has become quite popular and [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-268" style="margin-left: 10px; margin-right: 10px;" title="WP Recent Posts" src="http://www.elegantwebdesigns.net/wp-content/uploads/2010/06/recentposts.jpg" alt="WP Recent Posts" width="150" height="150" />One of the key features of  WordPress is the ability to do basically anything with it. By just adding a little piece of code to the <em>functions.php, </em>to any of the pages, sidebar or to both many things can be achieved. Lately adding a list of recent posts to a blog has become quite popular and this can be done with just a few pieces of code.</p>
<p>As explained in the Codex, the first thing you need to do is add this piece of code to where you want your recent posts to appear. In this example we&#8217;re going to place it in the <em>sidebar.php</em> but you can place it basically anywhere.</p>
<blockquote><p>&lt;?php wp_get_recent_posts( $num ) ?&gt;</p></blockquote>
<p>By default <span style="color: #888888;"><em>$num</em></span> will pull the 10 most recent posts, but you can add any number you want. Now this piece of code is quite simple and not necessarily too efficient, so you might want to dress it a little bit more like in the example below, so each title becomes a link to the actual post.</p>
<blockquote>
<div id="_mcePaste">&lt;h4&gt;Recent Posts&lt;/h4&gt;</div>
<div id="_mcePaste">&lt;ul&gt;</div>
<div id="_mcePaste">&lt;?php $recent_posts = wp_get_recent_posts(5); //Shows 5 most recent posts</div>
<div id="_mcePaste">foreach($recent_posts as $post){</div>
<div id="_mcePaste">echo &#8216;&lt;li&gt;&lt;a href=&#8221;&#8216; . get_permalink($post["ID"]) . &#8216;&#8221; title=&#8221;Look &#8216;.$post["post_title"].&#8217;&#8221; &gt;&#8217; .   $post["post_title"].&#8217;&lt;/a&gt; &lt;/li&gt; &#8216;;</div>
<div id="_mcePaste">} ?&gt;</div>
<div id="_mcePaste">&lt;/ul&gt;</div>
</blockquote>
<p>By running this code you will get the 5 most recent posts but that will include the private ones, drafts and even the published ones, which is not exactly what you want. Last thing anyone wants is to show a lists of drafts and private posts as by default these won&#8217;t render, so the solution is very simple.</p>
<blockquote><p>Locate and open the <em><span style="color: #888888;">wp-includes/post.php</span></em> file. At around line 2039 you will find this piece of code:<br />
/**<br />
* Retrieve number of recent posts.<br />
*<br />
* @since 1.0.0<br />
* @uses $wpdb<br />
*<br />
* @param int $num Optional, default is 10. Number of posts to get.<br />
* @return array List of posts.<br />
*/<br />
function wp_get_recent_posts($num = 10) {<br />
global $wpdb;<br />
// Set the limit clause, if we got a limit<br />
$num = (int) $num;<br />
if ( $num ) {<br />
$limit = &#8220;LIMIT $num&#8221;;<br />
}<br />
$sql = &#8220;SELECT * FROM $wpdb-&gt;posts WHERE post_type = &#8216;post&#8217; AND post_status IN (&#8216;<span style="color: #ff0000;">draft</span>&#8216;, &#8216;publish&#8217;, &#8216;<span style="color: #ff0000;">future</span>&#8216;, &#8216;<span style="color: #ff0000;">pending</span>&#8216;, &#8216;<span style="color: #ff0000;">private</span>&#8216; ) ORDER BY post_date DESC $limit&#8221;;<br />
$result = $wpdb-&gt;get_results($sql, ARRAY_A);<br />
return $result ? $result : array();<br />
}</p></blockquote>
<p>From it remove draft, future, pending and private leaving only publish, so the piece of code will look like this:</p>
<blockquote><p>/**<br />
* Retrieve number of recent posts.<br />
*<br />
* @since 1.0.0<br />
* @uses $wpdb<br />
*<br />
* @param int $num Optional, default is 10. Number of posts to get.<br />
* @return array List of posts.<br />
*/<br />
function wp_get_recent_posts($num = 10) {<br />
global $wpdb;<br />
// Set the limit clause, if we got a limit<br />
$num = (int) $num;<br />
if ( $num ) {<br />
$limit = &#8220;LIMIT $num&#8221;;<br />
}<br />
$sql = &#8220;SELECT * FROM $wpdb-&gt;posts WHERE post_type = &#8216;post&#8217; AND post_status IN (&#8221;, &#8216;<span style="color: #ff0000;">publish</span>&#8216;, &#8221;, &#8221;, &#8221; ) ORDER BY post_date DESC $limit&#8221;;<br />
$result = $wpdb-&gt;get_results($sql, ARRAY_A);<br />
return $result ? $result : array();<br />
}</p></blockquote>
<p>Save and upload the file again if using FTP or simply save if using the built in WP editor. Now only the published posts will appear when using the <em><span style="color: #999999;">wp_get_recent_posts</span></em> function.</p>
<p>UPDATE 1/11/2012:  As expressed by the many comments below, modifying the core files can be time consuming. Keeping up with the hundreds of updates these files go through every time a new version of WordPress comes out is a task on its own. Instead include the change only on the sidebar in this manner:</p>
<blockquote><p>/**<br />
* Retrieve number of recent posts.<br />
*/</p>
<div id="_mcePaste">&lt;h4&gt;Recent Posts&lt;/h4&gt;</div>
<div id="_mcePaste">&lt;ul&gt;</div>
<div id="_mcePaste">&lt;?php<br />
$args = array( &#8216;numberposts&#8217; =&gt; &#8217;5&#8242;, &#8216;post_status&#8217; =&gt; &#8216;publish&#8217; ); //Shows 5 most published posts only<br />
$recent_posts = wp_get_recent_posts( $args );<br />
foreach( $recent_posts as $recent ){<br />
echo &#8216;&lt;li&gt;&lt;a href=&#8221;&#8216; . get_permalink($recent["ID"]) . &#8216;&#8221; title=&#8221;Look &#8216;.$recent["post_title"].&#8217;&#8221; &gt;&#8217; . $recent["post_title"].&#8217;&lt;/a&gt; &lt;/li&gt; &#8216;;<br />
} ?&gt;<br />
&lt;/ul&gt;</div>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.elegantwebdesigns.net/2010/06/show-only-wp-recent-published-posts/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Google Chrome &amp; WordPress Image Float</title>
		<link>http://www.elegantwebdesigns.net/2010/06/google-chrome-wordpress-image-float/</link>
		<comments>http://www.elegantwebdesigns.net/2010/06/google-chrome-wordpress-image-float/#comments</comments>
		<pubDate>Sun, 27 Jun 2010 14:02:04 +0000</pubDate>
		<dc:creator>Editorial Staff</dc:creator>
				<category><![CDATA[WP Tips & Tricks]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[image float]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.elegantwebdesigns.net/?p=252</guid>
		<description><![CDATA[One of the problems we&#8217;ve seen happening over and over again with Chrome and Safari that doesn&#8217;t happen with Firefox and later version of IE is the image float issue of text not completely wrapping around the image when using the built in float tags in WP (.alignleft &#38; .alignright) which are automatically embedded in the code [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-254" style="margin-left: 10px; margin-right: 10px;" title="Image Float Chrome &amp; Safari" src="http://www.elegantwebdesigns.net/wp-content/uploads/2010/06/float.jpg" alt="Image Float Chrome &amp; Safari" width="150" height="150" />One of the problems we&#8217;ve seen happening over and over again with Chrome and Safari that doesn&#8217;t happen with Firefox and later version of IE is the image float issue of text not completely wrapping around the image when using the built in float tags in WP (<em>.alignleft</em> &amp; <em>.alignright</em>) which are automatically embedded in the code when the selection of aligning the image left or right are selected.</p>
<p>Both Google Chrome and Safari display it the same way, meaning the text doesn&#8217;t wrap around the image when using the simple <em>float:left;</em> or <em>float:right;</em> tags on your CSS.</p>
<p>The regular CSS tags that WordPress comes with are:</p>
<div id="_mcePaste"><span style="color: #33cccc;"><em><span style="color: #00ccff;">.alignright {</span></em></span></div>
<div id="_mcePaste"><span style="color: #33cccc;"><em><span style="color: #00ccff;">float: right;</span></em></span></div>
<div id="_mcePaste"><span style="color: #33cccc;"><em><span style="color: #00ccff;">}</span></em></span></div>
<div id="_mcePaste"><span style="color: #33cccc;"><em><span style="color: #00ccff;">.alignleft {</span></em></span></div>
<div id="_mcePaste"><span style="color: #33cccc;"><em><span style="color: #00ccff;">float: left</span></em></span></div>
<div id="_mcePaste"><span style="color: #33cccc;"><em><span style="color: #00ccff;">}</span></em></span></div>
<div>Many blogs have approached the  wrap the image around a division solution, but for those not too savvy when it comes to codding their posts there is an even easier way to solve this issue. By simply adding:</div>
<div>
<div><span style="color: #33cccc;"><em><span style="color: #00ccff;">img.alignright {</span></em></span></div>
<div><span style="color: #33cccc;"><span style="white-space: pre;"><span style="color: #00ccff;"><em> </em></span><em><span style="color: #00ccff;">float: right;</span></em></span></span></div>
<div><span style="white-space: pre;"><span style="color: #33cccc;"><em><span style="color: #00ccff;"> </span></em></span></span><span style="color: #33cccc;"><em><span style="color: #00ccff;">}</span></em></span></div>
<div><span style="color: #33cccc;"><em><span style="color: #00ccff;"><br />
</span> </em></span></div>
<div><span style="color: #33cccc;"><em><span style="color: #00ccff;">img.alignleft {</span></em></span></div>
<div><em><span style="color: #00ccff;">float: left;</span></em></div>
<div><span style="white-space: pre;"><span style="color: #33cccc;"><em><span style="color: #00ccff;"> </span></em></span></span><span style="color: #33cccc;"><em><span style="color: #00ccff;">}</span></em></span></div>
</div>
<div>to the <em>style.css</em> file on your theme the problem is solved and the images are displayed correctly on any browser.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.elegantwebdesigns.net/2010/06/google-chrome-wordpress-image-float/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

