Hi, I used this piece of code guideline: https://www.advancedcustomfields.com/resources/query-posts-custom-fields/, see topic “4. Sub custom field values”, where a wildcard is used to query with. This does not seem to work any more. Or at least not for me.
I am not sure why or how to fix it though. 🙂
No, this no longer works due to changes in WP, details can be found here https://make.wordpress.org/core/2017/10/31/changed-behaviour-of-esc_sql-in-wordpress-4-8-3/#comment-33131
This is only my opinion, but querying by repeater sub fields is a bad idea. You can see my entire opinion on the way this should be done here https://acfextras.com/dont-query-repeaters/
Thank so much John, that’s a great answer! 🙂
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 );