It is possible, but you’ll have to play a little bit with the actual query. As always, the furious posts_clauses
filter comes to action:
function wpse_alter_posts_search( $pieces )
{
global $wpdb;
// Make the input save
$search_string = like_escape( $_GET['s'] );
// Your new WHERE clause
$where = $wpdb->prepare(
"$wpdb->postmeta.%s LIKE %s",
'YOUR_COLUMN', // Should match your col name 1)
"%{$search_string}%"
);
// Not sure if this exactly the same on your install 2)
$pieces['where'] = str_replace( 'AND (((', "AND ((({$where} ", $pieces['where'] );
return $pieces;
}
add_filter( 'posts_clauses', 'wpse_alter_posts_search' );
NOTES
- Could be that you need to unserialize some parts to be search able.
- You better simply dump the
$pieces
to take a look into them, before altering the query (right after the$search_string
was received).
Related Posts:
- Admin Area Custom Type Search By Meta Fields Without Title & Content
- Extending the search context in the admin list post screen
- Advanced search form with filters for custom taxonomies and custom fields
- Development of a WordPress Search Plugin – Best Practices
- Search multiple custom fields by using meta_query
- How do I Paginate Search Results for Custom Post Types?
- Custom post type admin search
- Search that will look in custom field, post title and post content
- Prevent reload confirmation after AJAX save
- Search everything (posts, pages, tags, cpt, meta)
- Search Custom Post Type with all meta attached?
- WordPress Search documentation: how to improve search query using taxonomy terms, custom meta fields?
- Add custom column to custom post type overview in backend
- Backend search; include CPT meta?
- No results searching custom post type in admin panel
- How to search CPT’s by meta query from the admin dashboard?
- Search Custom Post Type Custom Fields
- Custom Fields vs Separate Table
- Including Custom Meta with posts_where query
- search also in taxonomy, tags and custom fields
- How to stick custom post at the top in search results
- Filter custom posts using auto populated dropdown selectors
- Including metaboxes from custom post types in global search — continued
- Displaying and searching Custom Posts
- Searching Custom Fields
- filter search custom field query
- How to let users choose where to search for posts?
- Add custom attributes to a post
- Custom Taxonomy Search result page
- search custom post type by custom fields on front end
- Category Search / Custom Post Type search on my website. Custom Post Types that are “page-like”?
- Best way to create a search for custom post type by custom field values
- Filtering custom posts by custom fields (ACF) [closed]
- Search CPT Title AND Meta
- Advanced search form with multiple custom fields
- Search facility with directories
- Search form to find custom meta box generated data
- Is it good practice to search for custom posts based on custom field values?
- Advanced search form with filters for custom taxonomies and custom fields
- WordPress CPT Taxonomy Dashboard Search – How to include taxonomy in search?
- How to sort WP_Query by a custom text field (written as a date dd/mm/yyyy)
- How to store the third party script with HTML code in the wordpress custom input field?
- Custom Post Type meta data getting deleted on bulk editing taxonomies
- Custom Form / Search with Custom Post Type Data
- How can I put content before my custom post type default pages?
- Custom fields array to display it monthly
- Copy data from 2 different ACF custom post types with relation
- Is it possible to get the specific content on the search page?
- Change search query in wordpress custom post type
- Creating a custom page post type just like the original “pages” post type using CPT UI
- Adding a location field to buddypress activity
- how to skip a CPT element from the pager by custom field
- Create if else for post types in WP_Query ‘post__in’ values
- WP Query from two Custom Post type fields as statement
- How to Print Title and Permalink of CPT Post behalf of Posts Meta Value with WP_Query
- Alike Shortcode using in Custom Shortcode
- Query custom post type that has a serialized relational advanced custom field value
- How To Read Read Custom Post Type Data in Headless CMS Mode
- Auto update publish date of CPT Post if default post custom field value match to cpt post CF Value
- Filter custom post type admin list by custom meta column, where the column is another custom posts meta value
- How we can create menu from Appearance > Menu and use as a add-submenu-page for admin menu?
- Using OR relation in meta_query to check for a value before sorting by another
- How to upload an image to a custom post type
- Search for custom field input of a custom post type in ajax live search
- WP Admin Dropdown List Filter for custom (ACF) field on custom post type(s)
- wp_set_object_terms creates taxonomies but does not add custom posts to it
- Updating a custom post status after an expiry date rather than trashing it
- WP_Query get always custom post_type for first
- Is there any filter to add a custom attribute to the tag in admin panel?
- Display Posts that fit a certain criteria on Category pages
- How to display custom field in product description?
- Sort custom post column by generated value?
- Custom Column in CPT admin table not updated after Quick Edit save
- How to only display all posts to a custom User Role?
- Why this didn’t work if i use get_the_ID(), but works if i pass the numeric id
- Create a post automatically if search result has zero results
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- How to keep custom post type related information
- What is the correct way that when creating a custom post type assign values to custom fields created with pods framework?
- when looping through custom post data not appearing
- How to avoid duplicate posts queried from custom meta?
- Custom Metabox Info Not Saving
- Add custom template ‘sub-page’ to Custom Post type?
- How can I query and sort custom-post type using WP_Query
- Meta query and compare “!=” not working as expected
- custom post types, custom fields and normalization
- Display Custom Field or Custom Taxonomy in front page /post/product
- How can I create a button that when clicked populates a div with a list of foods that are checked as a certain type of ACF?
- Orderby if between two meta fields
- Creating a custom WP query for a Custom Post Type
- In the php, how can I have a category of a custom post type display?
- How to add dynamic fields on wordpress custom post type page in admin section
- Search Function not searching correct custom_post_type even though post_type is defined in search args
- How to access repeater field of a custom field?
- Filter posts by their related field’s custom field
- Post Click Redirect to Custom URL instead of Single Post Page
- wp_insert_post deleting previous post custom meta
- How can I add a meta[] to my custom post type and search by term with the Rest API?
- Search only one custom post type
- Show posts from WP Custom Post Type selected from a field in a metabox