You could do two things:
A) replace the search with a SQL query that only searches the postmeta table (faster as there’s no JOIN
involved – you can get the post via it’s ID later on, when displaying the results).
B) Split the string right after WHERE 1=1
and drop the later part. You can use a simple return str_replace( $query_part_below, '', $search );
.
AND (
(whirl_2_posts.post_title LIKE '%__SEARCH_STRING__%')
OR (whirl_2_posts.post_content LIKE '%__SEARCH_STRING__%')
)
Make sure that you properly $wpdb->prepare()
before pushing it back in.
Related Posts:
- Add custom field (value) to search result (without plugin)
- How to display search query as formatted text?
- Search for meta_query does not return any result if combined with title
- Using meta query (‘meta_query’) with a search query (‘s’)
- Can I exclude a post by meta key using pre_get_posts function?
- Including custom fields in search?
- Add custom fields to search
- Custom search: by post data and post metadata?
- Show only posts which can be commented OR have custom meta field
- Need small coding with Custom Fields Search
- Filter results with custom field values and dropdown
- Is there a way to do multiple ordering on a multiple meta_query?
- searching in custom meta field
- WordPress Search Custom Meta Field Only
- Exclude custom post type from search by custom field value?
- Setting orderby to a custom field using pre_get_posts
- Extend ‘The Events Calendar’ search to include custom fields [closed]
- Include woocommerce custom field value in front-end search result
- Including Database Generated Pages in Site Search [closed]
- Using more than one meta_key in pre_posts_query
- Adding Custom Fields to Search
- sort search results by custom fields using dropdown
- Using a checklist to search against metadata
- How do I use wp_query for WordPress search?
- Including Custom Meta with posts_where query
- Custom Fields Not in Search Results
- How make a custom search on backend in WordPress without plugin?
- filtering custom post types via meta data drop down
- Advanced search by two criteria – sort by location and date (ascending or descending)
- How do I have WP_Query match posts based on search parameter OR meta fields? (rather than search parameters AND meta fields)?
- Why the pagination for a query modified by pre_get_posts doesn’t mind the number & order of posts sorted & selected based on a custom date time field
- How do I hide posts across all loops based on the value of a custom field?
- Advanced search for meta fields
- Merge Multiple Custom Fields into one New Custom Field for Searching
- Change the main loop WordPress impact on the server?
- Removing “s” from search with custom parameters
- How to populate custom field dropdown box based on prior selection?
- Search in Archive Pages by subcategory, tag, custom field and year
- Custom WP_Query for WordPress Search Results with meta_query
- filter custom field values $min $max
- Restrict WordPress Search to Custom Field
- How can you include custom post meta in search without calling each key?
- pre_get_posts : only get posts by wp_usermeta value
- How to use pre_get_posts to alter posts_per_page of category pages, where ‘posts_per_page’ will be dynamic
- Modify date query by URL parameter using pre_get_posts and $_GET
- Include one custom field in search results
- Custom search SQL Query to add custom field in result
- Search Results Page – Displaying Custom Meta Fields
- Custom field Search with Relavanssi
- How to exclude custom fields from search queries?
- How to show content of custom fields in search results?
- Searching with Multiple (Parallel) Criteria on Custom Fields?
- Need to search a custom field (ingredients, one long string per post), but want it to allow phrases/non-exact matches
- Type character in name and make it invisble
- Search & column order by meta value in admin
- Woocommerce products search with custom fields
- Setting user permissions per post
- search based on custom field
- Very large list of options for BuddyPress profile fields
- searching by keywords in post’s metas or pagination links problem
- Search fails when using the radio buttons
- Admin – Search Events by a custom field
- Search one custom field?
- Create custom query for search?
- Query postmeta values, and return multiple post_titles for common meta value
- Query Custom Fields in Searchform
- Help sorting by Meta Key value
- Custom search with meta fields
- Sort posts by numeric value of custom field, and also show any other posts without that custom field
- Filtering output by two custom fields using posts_where and add_rewrite_rule
- Sort posts by numeric value of custom field, and also show any other posts without that custom field
- Search by Custom Field content OR post id via the WordPress Dashboard
- Get custom field from page, in a post?
- Echo text if field under user_meta is empty with get_users()
- Hard Define Custom Field Value
- Filtering posts by WORD in custom field
- Use Metabox to enter Post Title
- Parse Shortcodes in Theme’s Custom Field?
- Include custom fields into the content of a regular page
- Basics: adding template tag to display custom fields in the post
- Bypassing a Form Options
- Create widget that filters posts on current page based on entered value
- Undefined Variable (Displaying image via custom field)
- I would like to display different text on different pages
- Adding custom field to Lightbox in header only pulls current page data, not Lightbox item data
- Meta boxes not displayed, data isn’t being saved
- Exclude empty fields from custom field calculation (Average)
- Semi-Private Comments + page comments -> is it possible?
- Cannot get tags working from a WPAlchemy metabox with wp_editor()
- Alter SQL query to return posts with unique custom field value, no duplicate values
- show custom field content in jquery tabs
- custom field output after the_content
- How to create Parent-Child relation for custom fields?
- Custom fields / meta box output
- Create citation and url in post using 3 custom fields with conditions for each field… So close!
- How to organise via Custom Fields on Category Page
- How to query posts that have certain post meta keys, and sort by meta key and/or value
- Insert shortcode before and after a list automatically
- Calling Custom Field within Function wrapped with Divs.
- How to check if custom field exists in this widget query