Sorting posts ordered by custom field value

I have a series of posts (using a wp-zoom theme). I would like to create a custom field called order and sort by that field.

Here is part of my homepage code:

<?php 
$z = count($wpzoom_exclude_cats_home);
if ($z > 0) { 
    $x = 0; 
    $que = ""; 
    while ($x < $z) {
        $que .= "-".$wpzoom_exclude_cats_home[$x]; 
        $x++;
        if ($x < $z) {
            $que .= ",";
        } 
    } 
}      
query_posts( $query_string . "&cat=$que" );
if (have_posts()) : 
?>

Related posts

Leave a Reply

1 comment

  1. You can use the “orderby” parameter of query_posts.
    You must specify your custom field and you must give it a numeric value.
    Short example:

    query_posts($query_string . "&cat=$que&orderby=meta_value_num&meta_key=your_custom_field")