You’re gonna need regular expressions to accomplish that.
First of all, you need to change 'LIKE'
to 'RLIKE'
(or 'REGEXP'
).
Second, replace $keyword
in 'value'
with a regex that involves word boundaries.
Like so:
$queryArgs = array(
'post_type' => 'faculty',
'posts_per_page' => -1,
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'proposed_keywords', // name of custom field
'value' => "[[:<:]]$keyword[[:>:]]", // matches exaclty "123", not just 123. This prevents a match for "1234"
'compare' => 'RLIKE'
)
)
);
Related Posts:
- Return parent post with its children using WP_Query?
- How does reset_postdata restore the post of the main query loop?
- Differences Between WP_Query() and get_posts() for Querying Posts?
- Escaping WP_Query tax_query when term has special character(s)
- Loop through all tags & output posts in alphabetical list
- Pagination with 5 posts per page
- Is there an action/filter called when WP_Query->query is finished and assigns posts
- How to support multiple search terms query within one process?
- Order posts by date and then by custom field
- Order by the results of a function with WP_query
- Pagination not working for category posts
- How to speed up wp_query, took more 5s to run against 100k posts
- How to sort posts in admin by titles with dd.mm.yyyy format?
- Why I can’t get old posts instead of recent with WP_Query?
- How get posts from a subcategory of a category by name?
- Date query not inclusive despite parameter being true
- Change default ordering of taxonomy terms – pre_get_terms
- Exclude old events from WP_Query with date saved in a `meta_key`
- WP_Query arguments to fetch custom post type posts which are in certain category?
- WP_Query loop within WP_Query loop
- current_post not working – give me -1 for every post
- Search Posts with Custom Fields as query
- Use query->set or make new query?
- How to fetch only media that was already attached to a post/page?
- (Solved) WP_Query ($ args) -> How to sort letters and numbers within the same array
- WP_Query won’t retrieve raw HTML?
- Remove a specific category ID from related post
- Order posts by taxonomy count
- Any number in meta key (wp query)
- Custom Metabox data slow query on Admin init
- WP_QUERY to display woocommerce products whose author IS the logged in user
- Use Repository Pattern in WP theme
- WordPress Comments sort by custom meta key
- Order by summing multiple values
- Understanding the orderby in WP_Query?
- Need Help For WPQuery
- When variable value have space between word, doesnt show any result WP_Query
- query_vars overriding WP_Query args
- Posts published last 10 minutes
- How should I approach changing the template & $query as part of a shortcode’s execution?
- Exclude All Posts Which Do Not Have A Tag Assigned
- pre_get_posts – Trying to get property of non-object warning
- Replacing search results with custom external query
- Getting additional columns from sql
- get all posts associated with a custom taxonomy
- WordPress query posts with multiple post_meta data
- How to use if($wp_query->query_vars[‘name’] == ‘pagethatdontexist’) without getting a 404? How to suppress 404
- complex get_posts() query to select child pages
- How to add $args to any running wp_query from function.php?
- var_dump of WP_Query object is not empty, while .have_posts() return false
- Show posts of an advanced search form
- Query using string from custom field as array value
- How to view all posts of current day as default in admin
- How to show list of posts with custom field value (a date) that are coming soon
- posts_per_page is not working
- Widget only in first post
- WP_Query meta compare must include ALL array values
- How can I change the term “Published” next to # of posts published on WordPress dashboard All Posts page?
- Multiple loops breaking side bar
- $post in wp_query?
- meta_query weird behaviour, static int will work, but not user data
- search through “product title” using WP_Query?
- How to make the WP query search for the “s” arg in other places too
- Excluding posts from search results page with meta query not working
- Counting instances of words in the results of a post query
- WP_Query for a taxonomy value OR a custom post type meta field
- WP_query pagination on frontpage
- WP Query by 4 different taxonomies
- WordPress Query by Category using Post Slug
- WordPress custom search form – ignore empty/default input fields upon submission?
- WP Query for all events prior to current date
- list all post who have mutual taxonomy as current taxonomy!
- How to extend WP_query to a specific table?
- How to rearrange posts based on input field values added by WordPress “Advanced Custom Fields”
- Display Search Results by tag_ID in my search.php
- What’s causing an infinite loop?
- Displaying posts from sub taxonomies only
- Logging search queries for logged-in users
- pages shortcode filtering by category
- get term objects and post objects in query
- How to show terms from another taxonomy
- Issue generating custom filter for cpt admin columns
- I cannot get tax_query in get_posts() to work with custom taxonomy
- Related Posts with removing some categories
- WordPress custom query by archive title
- How to take parameters from a function and make them editable as attributes in a shortcode
- Object of class WP_Query could not be converted to int inside shortcode
- display post multiple times based on array of dates
- Is it possible to search for a string in posts OR postmeta?
- What method does this eventually call: do_action_ref_array( ‘parse_query’, array( &$this ) );
- WP_Query secondary query failing
- WP_Query Posts by Metadata from Option Tree
- Sorting is not working in WordPress WP_Query
- Add custom WP_Query after the first 3 posts
- Weird results using wp-query with ‘date_query’ for last week
- How to count post meta key values for all posts in database
- Not duplicating $post->ID leaves empty space.
- Why won’t my paged wp_query work? [duplicate]
- How to add a custom field and incrementing value for all the published posts
- Excluding a category from frontpage but not from WP_Query