Home › Forums › ACF PRO › ACF Post Object meta-query by title not ID › Reply To: ACF Post Object meta-query by title not ID
You cannot do a query using the title of the related post. This information is not stored, only the post ID is. It is possible if you copy the title of the related post and store it with the posts you want to search. Something like
add_filter('acf/save_post', 'copy_country_title', 20);
function copy_country_title($post_id) {
// get the value of the country field
$country_id = get_field('intervention_country', $post_id);
$country_title = get_the_title($country_id);
// now store this value in a new meta field
update_post_meta($post_id, 'intervention_country_title', $country_title);
}
then you can use the new field intervention_country_title
for your query
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.