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 by mime type not working in pre_get_posts
- search filter for search and tag page doesn’t work
- Consistent and Admissible Heuristics
- Solr vs. ElasticSearch
- How do you make Vim unhighlight what you searched for?
- grep for special characters in Unix
- Search is always exact [closed]
- Using meta query (‘meta_query’) with a search query (‘s’)
- how to limit search to post titles?
- How to create live autofill search?
- How can I implement a location based (zip code) search in WordPress?
- How to highlight search terms without plugin
- How do I remove Pages from search?
- Empty search returns home page, how to return not found search page?
- How to search for (partial match) display names of WordPress users?
- How to make search include data from wp_postmeta?
- How does WordPress search work behind the scenes?
- Remove some pages from search
- Limit search to latin characters
- How to look at code in WordPress repositories without downloading?
- Extend WordPress search to include user search
- Display search results within the same page
- Empty search input returns all posts
- How can i move search results onto a specific page?
- Using pre_get_posts to rewrite search query to display posts from multiple taxonomies
- Remove meta robots tag from wp_head
- WordPress blog with 30 000 posts: poor search performance
- Custom search filter causes menu and query_posts problems
- Template issues getting ajax search results
- Insert DIV container below 1st search result
- Unified search across separate WordPress installations
- Search in WordPress – Difference of searchpage.php, searchform.php and search.php?
- Using meta_query on pre_get_posts to exclude a particular meta_key value
- How to make WordPress search prioritise page titles?
- How to add the author search in the default wordpress search?
- Add custom fields to search
- How do I filter the search results order?
- How to insert a span inside a search form?
- How do I redirect /search/ to wordpress search template?
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- How to search for users based on added user metadata
- Search by Post ID and display content of the post in search result
- Extending search query with additional $sentence value
- Link to search page without search parameter
- Order Search Results Page by meta_value If no Value Return Remaining Results
- Search/Replace for editor in HTML-mode
- How do I search events between two set dates inside WP?
- Search only blog posts (default WP search widget)
- Exclude pages from WordPress search result page
- How to pass a search $_GET parameter to a new custom search page?
- Do I need to sanitize WordPress search query?
- Disable Redirect to Product Page on Search Results Page in WooCommerce [closed]
- Search Using Post ID
- Neither the_excerpt() nor the_content() works properly?
- Let user change posts per page
- Search ONLY by meta key / meta values
- Exclude top-level pages from search results
- WordPress 3.6, searchform.php problems
- Search in non-English language returns only one result
- Complex Search functionality. Advice needed
- Get user role by using user_id in buddypress
- How to use next_post_link and previous_post_link on single posts in search results
- Why is there a class=”screen-reader-text” on my search button?
- template_include for search.php makes WordPress think its on the home page
- Turning Broken URLs Into Search Terms?
- How can I implement faceted search with WordPress 3.x?
- can’t limit search to only pages
- Meta query interfering with orderby relevance
- Add custom field (value) to search result (without plugin)
- Add custom parameters to JSON API search query?
- Change the Search Base in a multi language wordpress
- Display posts from an author using search parameters (not author template/query_posts)
- Search: Only One Result Returned