• I am trying to sort posts within a category using a custom field. I have used this code sucessfully to sort all posts:

    $querystr = "
        SELECT wposts.*
        FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
        WHERE wposts.ID = wpostmeta.post_id
        AND wpostmeta.meta_key = 'resolution'
        AND wposts.post_status = 'publish'
        AND wposts.post_type = 'post'
        ORDER BY wpostmeta.meta_value ASC
     ";

    But I am unable to restrict this query to the category that that is currently being displayed. I tried to use the code in http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query but it doesn’t work.

    Thanks

The topic ‘Sorting custom fields within a category’ is closed to new replies.