• Currently I’m using this to sort posts by title:
    <?php $posts = query_posts( $query_string . '&orderby=title&order=asc' ); ?>
    I placed the code in index before the loop starts. See the pastebin if you wanna see it all:
    https://pastebin.com/MkbL3yZy

    But how do I sort posts by meta value? Simply changing title with meta_value doesn’t work for me.

    Any ideas? ??

Viewing 1 replies (of 1 total)
  • Did you also use the meta_key parameter in the query?

    <?php $posts = query_posts( $query_string . '&orderby=meta_value&meta_key=mymetakey&order=asc' ); ?>

    Replace ‘mymetakey’ with the key of your Custom Field.

    You may need to use orderby=meta_value_num if the values are numeric.

Viewing 1 replies (of 1 total)
  • The topic ‘Sorting posts by meta value’ is closed to new replies.