Home › Forums › Add-ons › Repeater Field › Order custom post by sub custom field values › Reply To: Order custom post by sub custom field values
Hi @PrIInT
Thanks for the question.
Just to clarify this concept. It is not possible to sort posts by a custom field value, where each custom field value has multiple values (multiple rows of data in a repeater field).
This said, it IS possible to sort the data if you only want to use the ‘first’ row from the repeater field. This means that WP has one meta_value per post and can then sort as per usual!
at the moment, your orderby meta_key query looks like this:
'offres_fournisseurs_%_prix'
All you need to do is construct the exact meta_key which exists in the database. You are extremely close, but need to cahnge the wildcard (%) to 0 to target the first row:
'offres_fournisseurs_0_prix'
Hope htat helps.
Thanks
E
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.