Sort category page with custom field

I added the query_posts so we can tell WordPress of a modified query to run.
$query_string will let us add onto the current parameters.
orderby, meta_key, order let us define the query by telling it how to sort the results
More information on ordering by parameters

<?php wp_reset_query(); ?>
<div id="content">

  <div id="postFuncs">
    <div id="funcStyler"><a href="#" class="switch_thumb"></a></div>
    <?php if (is_category()) { 
      $cat_ID = get_query_var('cat'); ?>
      <h2><?php wpzoom_breadcrumbs(); ?></h2>
    <?php } elseif (!is_category() && !is_home()) { ?>
      <h2><?php wpzoom_breadcrumbs(); ?></h2>
    <?php } else { ?>
      <h2>Recent Videos</h2>
    <?php } ?>
  </div><!-- end #postFuncs -->

  <div id="archive">

    <?php global $query_string;
    query_posts( $query_string . '&orderby=meta_value_num&meta_key=your_custom_field"&order=ASC');
    if (have_posts()) : ?>
    <ul class="posts posts-3 grid">
    <?php $i = 0;  
    while (have_posts()) : the_post();
      $i++;
    ?>

Leave a Comment