Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Problem sorting WordPress post by custom field

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #30856
    swirv
    Participant

    I am doing a theme for a client that needs to sort custom posts by a custom field. This sounds easy, especially sense we have orderby=mete_value_num. This works great unless you have numerical values above 100,000, say like the price of a house. The important bit of my current query looks like this

    $my_query->query( array( 'listing-area' =>'lake-murray-lakefront', 'post_type' => 'homes',  'posts_per_page' => '-1', 'meta_key' =>'price', 'orderby' => 'meta_value_num', 'order' => 'DESC' ) );

    ..where ‘price’ is my custom field. It sort of sorts them. But not in the correct order.

    What am I doing wrong? How can I get these posts to be sorted in the correct order. I have Google’d for hours looking for a solution that will fit into WP. Any help will be greatly appreciated.

Viewing 1 post (of 1 total)
  • The forum ‘Other’ is closed to new topics and replies.