Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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()) : 
?>
share|improve this question

1 Answer 1

up vote 2 down vote accepted

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")
share|improve this answer
    
This is awesome - thanks so much! –  redconservatory Feb 26 '11 at 1:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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