Udders
Udders

Reputation: 6986

wordpress ordering posts by value held in an acf field

I am wanting to order some posts by "price" this is a value that is held in a number field the acf plugin.

I reorder the posts based on some params in the URL, the params then build a query string which I appends to the existing query string that build the loop in my archive template, my query in my archive page would look like this,

post_type=used-cars&meta_key=price&order_by=meta_value&order=desc

now regardless of the weather order is desc or asc the order does not change, so I am assuming is wrong withe query can anyone shed any light in to this for me pleae? How do I use an acf field to order my posts?

Upvotes: 0

Views: 100

Answers (1)

DubVader
DubVader

Reputation: 1072

Try removing the underscore from the orderby param, like so:

post_type=used-cars&meta_key=price&orderby=meta_value&order=desc

Upvotes: 1

Related Questions