Home › Forums › General Issues › Ordering by field order
Is it possible, to order by field order?
In the admin I can order the fields, but I have no idea how could I display the data in the same order.
$args = array('post_type' => 'product',
'posts_per_page' => 1,
'orderby' => 'meta_value_num',
'order' => 'ASC');
$the_query = new WP_Query ($args);
Hi @vakondweb
Yes, you are on the right track.
Your args are missing the meta_key for the order param to work correctly.
Perhaps you just need to have another look at the docs:
http://www.advancedcustomfields.com/resources/how-to/orde-posts-by-custom-fields/
http://codex.wordpress.org/Class_Reference/WP_Query
Thanks but I have no idea what to put to the meta key.
I cant find any reference regarding it. 🙁
$args = array(‘post_type’ => ‘product’,
‘posts_per_page’ => 1,
‘meta_key’ = ‘?????’
‘orderby’ => ‘meta_value_num’,
‘order’ => ‘ASC’);
$the_query = new WP_Query ($args);
Hi @vakondweb
the meta_key will be the name of the field you want to order by.
How else would PW know what custom field value to use as the ordering?
But I want to use the order info from the admin.
I would like display in the same order as I ordering the custom fields in admin area. I cant find meta key for doing this…
Hi @vakondweb
Sorry, I dont understand what you are saying.
Perhaps you should return to the original question and ask how to achieve the output you desire instead of asking about the meta_order argument.
The WP_Query object is for querying posts in WordPress, this is different to loading ACF values. Does this help? Perhaps you are a bit confused and did not mean to use the WP_Query?
Could this be correct?
The topic ‘Ordering by field order’ is closed to new replies.
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.