<?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; Custom Fields</title> <atom:link href="http://wpengineer.com/tag/custom-fields/feed/" rel="self" type="application/rss+xml" /><link>http://wpengineer.com</link> <description>WordPress News, Hacks, Tipps, Tutorials, Plugins and Themes</description> <lastBuildDate>Wed, 28 Jul 2010 13:37:05 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=4140</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/sort-posts-custom-fields/</link> <comments>http://wpengineer.com/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/blog/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/blog/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><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;">query_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'meta_key=my_day&amp;meta_compare=&lt;=&amp;meta_value=20&amp;orderby=meta_value&amp;order=DESC'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><div
class="incontent"><h4>Guest Post</h4><p>This post is written by Sergej Müller <a
href="http://www.wpseo.org" class="liexternal">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" class="liexternal">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
/><h3>Related posts:</h3><ul><li><a
href="http://wpengineer.com/custom-fields-in-your-feed/" rel="bookmark" title="Permanent Link: Custom Fields in your Feed" class="liinternal">Custom Fields in your Feed</a></li><li><a
href="http://wpengineer.com/display-private-posts-to-logged-in-users/" rel="bookmark" title="Permanent Link: Display Private Posts to Logged in Users" class="liinternal">Display Private Posts to Logged in Users</a></li><li><a
href="http://wpengineer.com/strange-things-with-sticky-posts/" rel="bookmark" title="Permanent Link: Strange Things With Sticky Posts" class="liinternal">Strange Things With Sticky Posts</a></li><li><a
href="http://wpengineer.com/wordpress-3-0-menu-update/" rel="bookmark" title="Permanent Link: WordPress 3.0 Menu Update" class="liinternal">WordPress 3.0 Menu Update</a></li><li><a
href="http://wpengineer.com/easy-way-for-advertisement-in-wordpress/" rel="bookmark" title="Permanent Link: Easy Way For Advertisement In WordPress" class="liinternal">Easy Way For Advertisement In WordPress</a></li></ul><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/" class="liexternal">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/" class="liinternal">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p> ]]></content:encoded> <wfw:commentRss>http://wpengineer.com/sort-posts-custom-fields/feed/</wfw:commentRss> <slash:comments>8</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Database Caching 28/34 queries in 0.061 seconds using disk
Object Caching 454/516 objects using disk

Served from: wpengineer.com @ 2010-07-29 13:38:45 -->