<?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>WP Engineer &#187; Sort</title>
	<atom:link href="http://wpengineer.com/tag/sort/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpengineer.com</link>
	<description>WordPress News, Hacks, Tipps, Tutorials, Plugins and Themes</description>
	<lastBuildDate>Tue, 31 Aug 2010 10:00:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Sort Posts With The Help Of Custom Fields</title>
		<link>http://wpengineer.com/1915/sort-posts-custom-fields/</link>
		<comments>http://wpengineer.com/1915/sort-posts-custom-fields/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 06:43:33 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[Custom Fields]]></category>
		<category><![CDATA[Sort]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=1915</guid>
		<description><![CDATA[Quite often, a WordPress developer likes to have posts sorted according to a custom field. If you would write a SQL-statement, it would be quite complex, since you need to JOIN two database tables (wp_posts und wp_postmeta). But there is a much easier way, if you use the template tags provided by WordPress - in [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://wpengineer.com/wp-content/uploads/WordPress-Christmas-17.jpg" alt="WordPress-Christmas-17" title="WordPress-Christmas-17" width="600" height="400" class="aligncenter size-full wp-image-1895" />Quite often, a WordPress developer likes to have posts sorted according to a custom field. If you would write a SQL-statement, it would be quite complex, since you need to JOIN two database tables (wp_posts und wp_postmeta).</p>
<p>But there is a much easier way, if you use the template tags provided by WordPress - in our case we use the function query_posts. Below you can see an example, which includes a custom field in the query, and also sort the posts with the help of this custom field. A short, easy to understand code with effective result:</p>
<p><img src="http://wpengineer.com/wp-content/uploads/Bildschirmfoto-2009-12-04-um-21.49.05.png" alt="Bildschirmfoto 2009-12-04 um 21.49.05" title="Bildschirmfoto 2009-12-04 um 21.49.05" width="577" height="271" class="aligncenter size-full wp-image-1916" /></p>
<pre lang="php">query_posts(&#039;meta_key=my_day&amp;meta_compare=&lt;=&amp;meta_value=20&amp;orderby=meta_value&amp;order=DESC&#039;);
</pre>
<div class="incontent">
<h4>Guest Post</h4>
<p>This post is written by Sergej Müller <a href="http://www.wpseo.org">wpseo.org</a> and is a post in our Advent Calendar on WP Engineer about WordPress.<br />
Thank you very much from my part to <a href="http://www.wpseo.org">Sergej</a>.<br />
If you also like to have your interesting post published on our website, please let us know on our contact page. Of course we will appreciate your contribution!
</div>
<hr />
<p><img style="float:left;" src="http://wpengineer.com/favicon.ico" alt="WP Engineer Favicon"/> Thanks for subscribing our feed! <a href="http://buysellads.com/buy/detail/3646/">Sponsor the WP Engineer Blog</a> and get your brand in front of several hundred users per day!<br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/1915/sort-posts-custom-fields/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
