Home › Forums › General Issues › Ordering by custom field of relationship field object › Reply To: Ordering by custom field of relationship field object
So how would I use /query as you mention? In other words do I just change the top part of the code and that is it?
Like this to add the sorting ASC?
add_filter('acf/fields/relationship/query/name=jam_related_home_listing', 'my_acf_fields_relationship_query', 10, 5);
function my_acf_fields_relationship_query( $text, $post, $field, $post_id ) {
$community = get_field ('community', $post->ID);
$sqft = get_field('sq_ft', $post->ID);
$mls = get_field('mls', $post->ID);
$price = get_field('price',$post->ID);
$lot = get_field('lot', $post->ID);
if ($post->post_type == 'home_listings') {
return "wp_posts.menu_order ASC";
}
$text .= ' • ' . $community->post_title . ' • Lot: ' . $lot . ' • SqFt: ' . $sqft . ' • MLS: ' . $mls . ' • Price: ' . $price . '';
}
return $text;
}
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’re excited to announce we've released Composer support for installing ACF PRO.
— Advanced Custom Fields (@wp_acf) January 31, 2023
🎉 #ComposerPHP fans rejoice!
✨ Please see the release post for all the details and full instructions. https://t.co/ebEfp61nlR
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.