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:

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

1 Answer 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")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.