Have you tried it with add_action instead of add_filter ?
add_action('pre_get_posts', 'search_custom_fields');
Is public set to true for your post_type?
And for use on in admin, try:
if ( is_admin() && $query->is_main_query() ) {
if ( $query->is_search ) {
//etc.
Related Posts:
- WP search in metadata post
- WP User Query with search columns and meta query
- Combining Meta_Query key values for one array
- filter search result with custom post type meta key
- Create multiple Search functions for posts / custom post types and everything
- Comparing between a negative and positive number
- Advanced Search by minimum/maximum values
- Search function works improperly
- Searching by meta values showing inappropriate result
- Force is_search to always TRUE
- How to conditionally pass a parameter to wordpress search to limit post types?
- WordPress, fetching users with an exact match in a string of comma separated values in user_meta
- Meta query: How do I return posts within a date period from a given month?
- meta_query issue with multiple numerics
- How to exclude pages from WP search based on page title
- why pre_get_posts works fine in post type archive, but not in search result list?
- Custom Query Content Filtering
- Search for two strings in WP search
- Displaying number of search results for each post type
- Search by meta_query
- Sorting search results with custom dropdown
- Exclude posts with certain meta data from search results
- Use pre_get_posts to display search results by meta in specific order
- Search custom posts by meta key in admin
- Form for search pages by meta datas
- pre_get_posts improperly searching revisions
- meta field search too restrictive in pre_get_post() for custom search
- search filter for search and tag page doesn’t work
- How to search for (partial match) display names of WordPress users?
- How can i move search results onto a specific page?
- Unified search across separate WordPress installations
- Using meta_query on pre_get_posts to exclude a particular meta_key value
- Add custom fields to search
- How to insert a span inside a search form?
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- Extending search query with additional $sentence value
- Search only blog posts (default WP search widget)
- Exclude pages from WordPress search result page
- Disable Redirect to Product Page on Search Results Page in WooCommerce [closed]
- Search: Only One Result Returned
- How to redirect search result page to post
- Custom Permalinks Break Search Pagination
- Include Author profile in search results
- Adding arg to search results page
- search only pages if on page
- WordPress search not searching pages’ content
- Search by type posts and taxonomy
- Make Search Function include subdomain (blog.ourwebsite.com)
- Replace default WordPress search behavior with Sphinx
- How to disable WordPress Search from Url?
- More than one search results page template
- Changing search slug from + to – (hyphen)
- Add search box to page
- Plugin: Events Manager – Search by start date only
- Worried I have a funky .htaccess for WP site in light of strange search engine behavior
- Quick and Easy way to Add Search to the P2 Theme?
- Get PDF in media by ID
- Display post matching the exact search term
- Show only “Pages” – not posts – on search page
- remove post edit.php search form and replace with my own
- Get most searched keywords in WordPress
- Search bar in table in wordpress
- Where does the Yoast SEO plugin set the Open Graph metadata?
- search filter add priority to post_type and add order to some post_type
- How do I add custom fields data to a search index?
- Empty search results return soft 404
- How do I search events between two set dates inside WP?
- searchform.php :: pass second query string variable with same value as ?s=
- Limit search to custom field
- How can I get a traceback on function calls?
- Limit search to a specific folder in website
- How do i append UNION SQL Query with default search query
- Why is this search form not submitting when button is clicked?
- Search within table?
- Custom search page wont allow URL params
- Included posts on a page searchable
- How to remove notice inside search.php when no results are found?
- Changing search terms results a 403 – dsIDXpress Pro plugin [closed]
- search: get minimum number of post for each post type
- Order resultset by configured value and then list all the rest
- WordPress Search function with partial and exact match
- How to search in Elastic by post title/concerpt/content?
- WordPress meta query not working
- Why does this incorrect pre_get_posts meta_query work for sort order?
- how to disable autocomplete search on wpLink?
- Limit default Search query to post_title
- Use WordPress search in external static website
- How to show custom post type by either single meta_value or multiple meta_value(s) using WP_Query?
- Conditional posts in WP_query for search
- Create custom query for search?
- Insert DIV container below 1st search result
- Extend search function with link to searched word
- Search for Author and Custom Post Type
- Search page isn’t returning any results
- Adding attributes to the core search block form
- Custom taxonomy with custom meta value is not sorting correctly (query returns the same value for orderby regardless of sort column click)
- WordPress Search – Reject partial matches
- Wp query search built out of 4 terms?
- Loadmore search results not showing new results?
- How to get WordPress to ignore the search parameter in the frontend?