Wordpress:
Order by Custom Field
I've made a custom wordpress porfolio template for a client. The client didn't want to order the posts by date so I used a custom field with a number to set the order. The problem with custom fields is that the value is stored as a string in the database. That messes up the order: 500 is comes after 4000, 100 comes before 20 etc.
Solution
The solution is to force the value to become an integer. Some google ninja tricks later I found a way to hack the query.php-file, but when I started coding I found out that the feature already was implemented in Wordpress 3.0 (and maybe earlier versions such as 2.9.2, but who uses old versions anyway?). So instead of writing query_posts('orderby=meta_value&meta_key=order&order=ASC'); you simply change the orderby value to meta_value_num
So my finished query: query_posts('orderby=meta_value_num&meta_key=order&order=ASC');