Thanks @peterseb for this solution. Worked for me, on a Post Object field. In my case I needed users (admins actually) to be able to search for a post by its ID. Here’s my code for that:
function cf_post_object_query( $args ) {
// Set a query variable to identify the post object query
$args['is_acf_query'] = true;
// return
return $args;
}
// filter for a specific field
add_filter('acf/fields/post_object/query', 'cf_post_object_query');
function cf_search_where( $where, $wp_query ) {
global $pagenow, $wpdb;
$is_acf = isset( $wp_query->query['is_acf_query'] ) ? $wp_query->query['is_acf_query'] : false;
if ( is_search() || $is_acf ) {
$where = preg_replace(
"/\(\s*".$wpdb->posts.".post_title\s+LIKE\s*(\'[^\']+\')\s*\)/",
//"(".$wpdb->posts.".post_title LIKE $1) OR (".$wpdb->postmeta.".meta_value LIKE $1)", $where );
"(".$wpdb->posts.".post_title LIKE $1) OR (".$wpdb->posts.".ID LIKE $1)", $where );
}
return $where;
}
add_filter( 'posts_where', 'cf_search_where', 10, 2 );
There is a feature request for this at https://support.advancedcustomfields.com/forums/topic/acf-field-for-add-elementor-button/.
I don’t believe it is possible (at least not without custom-coding something like that), but it would be invaluable. I want to do the same thing. This would provide a degree of flexibility without letting the page design turn into a free-for-all.
A workaround (and not a great one) is that you can embed an Elementor template shortcode in the WYSIWYG editor area. For occasional use this would perhaps be OK. If you need to use Elementor on tons of pages, this is untenable, though.
I don’t believe it is possible, but it would be invaluable. I want to do the same thing. This would provide a degree of flexibility without letting the page design turn into a free-for-all.
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.