Home › Forums › ACF PRO › conditional sort › Reply To: conditional sort
What you’re trying to do can’t really be done, basically because sorting posts by two different meta keys and intermixing them in WP is beyond what WP is capable of. However, you can do this by saving the value of org_name
in the last_name
field when the post is saved.
add_filter('acf/update_value/name=org_name', 'insert_org_into_last_name', 10, 3);
function insert_org_into_last_name($value, $post_id, $field) {
// replace the value of $last_name_field_key
// with the field key of the last name field
$last_name_key = "field_123456789ABCD";
update_field($last_name_key, $value, $post_id);
return $value;
}
Now you can do a query and sort by last name. The value in last name will not be seen because it’s in a conditional field.
http://www.advancedcustomfields.com/resources/acfupdate_value/
http://www.advancedcustomfields.com/resources/update_field/
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.