Home › Forums › Add-ons › Flexible Content Field › Post order by Flexible Content custom field › Reply To: Post order by Flexible Content custom field
There isn’t any way within WP to order posts by a flex or repeater sub field.
The sub fields of these fields are stored using a meta key with that is constructed like this: "{$parent_name}_{$index}_{$sub_field_name}"
In order to do this you could possibly query the DB directly using $wbdp
Some parts of the query might look something like this. This is not tested.
SELECT post_id, wp_postmeta.meta_key LIKE "{$parent_name}_{$index}_{$sub_field_name}" AS date ORDERBY date ASC
You could then use the list of returned post ID value and use “post_in” and ‘order_by’ => ‘post__in’
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.