WordPress.org

Support

Support » How-To and Troubleshooting » Order a category by custom field

Order a category by custom field

  • I added this before <?php if (have_posts()) : ?> in my category template

    <?php if (is_category('5')) { $posts = query_posts($query_string. '&orderby=meta_value&meta_key=start_date&order=DESC' ); } ?>

    Trying to order by start_date custom field.
    But it doesn’t seem to work due to pagination.

    Any ideas?
    Tx

Viewing 1 replies (of 1 total)
  • See if this works:

    <?php if (is_category('5')) {
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts($query_string. '&orderby=meta_value&meta_key=start_date&order=DESC'.'&paged=' . $paged );
    } ?>

Viewing 1 replies (of 1 total)
  • The topic ‘Order a category by custom field’ is closed to new replies.