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
- Why does get_the_time(‘F j’) return November 30 for all posts?
- is_archive() doesn’t work on public query var archive pages?
- Possible to get posts from multiple meta keys/values in a single query?
- Difference between fragment caching and wp_cache
- How to display all posts with today’s same month and day only?
- Select User by Joining Multiple Meta Value Results
- How do I search inside specific taxonomies in WordPress
- Show featured image as background image from postQuery
- Using $wpdb->update but confused on the WHERE in and SET
- sort search results by custom fields using dropdown
- You have an error in your SQL syntax – Help with query
- Make one query for adding entries to database
- add_query_arg() and empty variables inside
- Query Strings and Woocommerce
- Style Post Differently In Query
- WordPress post type “event” query string fix?
- Overwrite YoastSEO meta-tags with another page’s [closed]
- How to orderby multiple meta fields if some fields are empty
- WordPress, fetching users with an exact match in a string of comma separated values in user_meta
- WordPress default Search function inconsistent in WooCommerce Product Titles
- Function to delete a post, it’s children and it’s grand children (half way there already)
- How to exclude posts for current user
- How many meta-query fields support WordPress search at a time?
- exclude pingbacks from wordpress SQL query
- wp_posts query slowing down my website
- Advanced Custom Fields – Relationship post foreach query
- How do I query for posts by custom meta and those that have been stickied?
- Select min/max meta from query
- How do I set the Stewart Search Template to return only published posts in the result
- Re-order search results with posts_orderby filter and post meta value
- Restore WordPress Backup Locally?
- Create a new post on a specified publish date via link?
- Exclude Posts from a Widget
- New custom post type entries are not sorted correctly in admin using pre_get_posts
- Query String for the WP_QUERY parameters
- Filter posts/pages by user_role array
- Sorting of coupons in the right way
- excludeCat function reverses order of blog posts
- Form Data Causes “Page Not Found”
- Where can I find the SQL to get the most used information by wordpress database?
- Query comments with non-empty ‘author_url’ value on Admin Comments Screen
- Advanced Search – Is this possible?
- How to show sticky posts on all pages of the pagination, not just the first page?