I ended up using a simple meta_query
:
$args = [
'post_status' => 'publish',
'post_type' => $post_type,
'orderby' => 'title',
'order' => 'ASC',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'my_acf_field',
'value' => $search_term,
'compare' => 'LIKE'
),
)
];
$query = new WP_Query($args);
Related Posts:
- How can I create a meta_query with an array as meta_field?
- How can I query all users who registered today?
- what are the numbers between curly brackets in search query
- Search custom post type by meta data
- Search Terms – Querying on either description__like OR name__like in the same Term Query?
- WordPress creating excessive joins on meta_query with search
- How to display liked posts of current user in wordpress?
- search through post-type attachments titles
- How can I apply a meta query for a single custom post type in the main query?
- How do I find if a page has a template?
- How to check current user in meta value array in WP_Query meta_query
- Change searched term
- Query metas (and not : query posts by metas)
- Search query -> Show all pages except certain template
- WP Query with custom Shortcode
- Temporarily storing main search result
- How to orderby multiple meta fields with another meta query
- Query based on title, with ‘compare’ => ‘IN’
- is_search called incorreclty
- Attempt to improve WP search, can someone check my SQL query?
- Searching With Apostrophe
- Query returning same results even though the ID changes
- How to reset usual $query on search page to push custom $wpdb query there?
- Order by meta value pro first then meta value free in my search function
- get_users with array as meta_value
- Ideas how to search & replace post_content when string contains a newline?
- How to insert Collate into WordPress search query?
- Slow Search Queries – How to exclude pages, media, excerpt, authors, private posts?
- How to interfere to default search to make it search in custom fields?
- How to manage a particular “order by” for get_search_query()?
- get_post_meta with WP_query
- WordPress Mysql query and Duplicate
- How to “orderby” the first array in a meta_query that uses multiply keys?
- WordPress search in modified post title
- Filter orders by modify date
- How to add url parameter to every search query in SearchWp?
- meta_query not working
- Add rewrite rule for archive search
- WordPress query: merge meta key (number) values and sort
- Is there any way to get all custom posts and all custom terms with it’s meta in few queries?
- Modify behaviour of “s” parameter in wp_query
- Sort by postmeta on when searching
- Pagination adds search query (again)
- Speed up search query that searches in post meta?
- How can I modify standard search query to include also ACF custom fields values?
- Fastest and most efficient SQL query to check if UID exists
- How to make MySQL search queries with quotes
- Query Posts that have or don’t have a meta_value and order by the same ASC
- $query->set( ‘post_type’, ‘post’ ); not working
- Conditional posts in WP_query for search
- What is the best way to query posts based on live data?
- Create custom query for search?
- search.php is not generating the right results
- Run search query again without pagination gives no results?
- list or get meta_key where meta_value is ‘something’
- WP_Query orderby meta key/value suddely stopped working
- Meta Query compare with LIKE pulls similar post types: 55 and 155, and 1,155
- is_search called incorrectly
- How to display SQL query that ran in query?
- Using meta query (‘meta_query’) with a search query (‘s’)
- Query multiple meta key values?
- How to Optimize WP site for millions of posts
- How to get comments by post ID?
- Differences between wpdb->get_results() and wpdb->query()
- Is there a way of increasing the speed of this query?
- Get all image from single page using this query
- Get Terms by IDs with IDs order
- Reversing the order of posts AFTER the query is performed
- simple sql query on wp_postmeta very slow
- Add custom fields to search
- Using WordPress public query variables
- How to Use Wildcards in $wpdb Queries Using $wpdb->get_results & $wpdb->prepare?
- When/why does ‘$query->get( ‘tax_query’ );’ return empty?
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- Meta Query with AND & OR?
- How to get link and title of next and previous post on single page
- Create pagination and order according to alphabet
- wpdb get posts by taxonomy SQL
- How to List Events by Year and Month Using Advanced Custom Fields?
- Is there any difference between hooks posts_where with posts_join and posts_search performance wise?
- Custom WP_Query order by post_meta and (author) user_meta
- wordpress query – orderby child post date
- Query WooCommerce orders where meta data does not exist
- How do I search events between two set dates inside WP?
- How many WordPress SQL Queries per page?
- Filter the query ONLY for the search results page
- How to display Section for certain time
- Add multiple value to a query variable in WordPress
- Custom query_var causes displaying posts archive on front page
- Slow wp_enqueue_media()
- Multipart/formatted MySQL query problem
- Custom Queries: Joining On Meta Values From Two Custom Post Types
- WP User Query with search columns and meta query
- What is the most efficient way of implementing a favorite post system?
- How do I create a meta box for dates?
- Remove [gallery] shortcode altogether
- Search and replace text across all posts
- Compare two numeric custom fields
- wp_dropdown_categories with multiple select
- Advanced Custom Fields – Query Efficiency