WordPress.org

Ready to get started?Download WordPress

Forums

Order a category by custom field (2 posts)

  1. vbob
    Member
    Posted 4 years ago #

    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

  2. MichaelH
    Member
    Posted 4 years ago #

    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 );
    } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic