Here in Papion headquarters we love using ACF.
Advanced Custom Fields is one of the best WordPress plugins for custom field management.
Recently, with the new WordPress 4.8.3, a change was made in theprepare query to the database.
Instead of characters like% now we have placeholders like{1872368126381726387126381276381726318723} (for more information see code).
It does not involve any major issues, except when we use ACF in combination with get_posts and metaquery to search forpost based on repeater fields that havemeta_key infieldgrup_%_field format like “fieldgrup_0_field”, “fieldgrup_1_field”, etc.
One of the solutions ACF proposes is (source)
1 2 3 4 5 6 7 | function my_posts_where( $where ) { $where = str_replace("meta_key = 'locations_%", "meta_key LIKE 'locations_%", $where); return $where; } add_filter('posts_where', 'my_posts_where'); |
However, with the update, instead of the “%” character, we find ourselves with a numeric placeholder, so this code should be changed so that the comparison is done with the query without placeholders:
1 2 3 4 5 6 7 8 | function my_posts_where( $where ) { global $wpdb; $where = str_replace("meta_key = 'locations_%", "meta_key LIKE 'locations_%", $wpdb->remove_placeholder_escape($where)); return $where; } add_filter('posts_where', 'my_posts_where'); |