Support

Account

Home Forums General Issues Custom field as 'orderby' value causes post grouping by publish date

Solved

Custom field as 'orderby' value causes post grouping by publish date

  • Very odd. I am using WP_Query. Here is my query:

    $my_query = new WP_Query('category_name=test-category&posts_per_page=-1&meta_key=sort_name&orderby=meta_value_num&order=ASC');

    Why is it grouping my posts this way?

  • By the sounds of it sort_name is a text field. orderby=meta_value_num WP converts the text field to a number so they all == 0. WP then sorts them by the default order which is by post date. try orderby=meta_value.

  • You are correct, John. That was it. Thanks so much.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Custom field as 'orderby' value causes post grouping by publish date’ is closed to new replies.