Home › Forums › Bug Reports › Query Posts by sub custom Field values › Reply To: Query Posts by sub custom Field values
Hi again John.
Could not get your code to work, the code you so kindly share here: https://acfextras.com/dont-query-repeaters/
So I modified it and had to use the field keys like so:
add_action('acf/save_post', function( $post_id ) {
$meta_key = '_book_authors';
$saved_values = array();
$authors = $_POST['acf'];
if( $authors ) {
foreach( $authors['field_55bf6c9024b5f'] as $key => $author ) { // field_55bf6c9024b5f: ACF field key for "book_authors" meta field
$author_id = $author['field_55dafbfa91614']; // field_55bf6c9024b5f: ACF field key for "book_authors" meta field
add_post_meta( $post_id, $meta_key, $author_id, false );
}
}
}, 20, 1 );
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.