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
- Using meta query (‘meta_query’) with a search query (‘s’)
- Remove meta robots tag from wp_head
- Template issues getting ajax search results
- How do I search events between two set dates inside WP?
- Include custom table into search results
- Search pre_get_posts filter which can handle multiple post types and categories?
- ElasticPress Indexing multiple sites
- How to search through pdf media files?
- WordPress Single Conditional for Search Page
- Comparing arrays with meta_query in pre_get_posts
- Do not allow to search certain words
- intellisense in wp search
- pre_get_posts filter meta_query without conflicting existing meta_query
- Get search term not on searh results page?
- Search Result from another wordpress website
- Remove WHERE conditions from search query
- Change default search URL slug in wordpress with Custop Post Type as Search target
- How make a custom search on backend in WordPress without plugin?
- Change WordPress search Permalink structure
- Media searching ignored
- search suggest – filter post type
- Generate list of tags from search results
- Use created page as search results page and custom template
- How do I search dynamically created content?
- Post 2 Post Site Search
- Using search.php without a ‘s’ field in searchform.php
- Search queries don’t seem to work?
- Array_search ignoring the first element [closed]
- Add Icon to Placeholder Text in Search Form
- Unexpected esc_html and esc_attr behaviour
- Search Results No Link
- Sort search results by Custom Field
- Order search results by category
- Strip HTML Tags From Search Results
- How to build an advanced search form by post type?
- Should I create a parent page with no content? [closed]
- find custom post type post by searching its custom field with my string
- adding more text to a query string
- Independent search tool that returns exact match of a post title
- Search using WP_Query
- When clicking on submit from my searchform it takes me to home.php
- My default search is not working
- Dashboard search function doesn’t work well
- My search form finds page 1 results but shows “error 404 page not found” on pages 2 on or clicking next
- twentyeleven theme: Where is the code that handles moving the search bar on resize?
- Displaying a list of tags in my archives page
- Page 2 of Search Results shows homepage
- Need to search a custom field (ingredients, one long string per post), but want it to allow phrases/non-exact matches
- Return All Tags from Search Result in Separate List
- Tax query get first product with attribute value in pre_get_posts
- Can I replace the search bar with Programmable Search by Google?
- Search within the current page
- What are the available options for “Name” in WP search?
- how to make search with two input boxes
- WordPress search with more input fields?
- WordPress search not able to find the category
- Editing a Search Form
- Pre get posts sort by meta key returns no results if meta key does not exist
- how to prevent the spam on search function?
- I have dynamic title tag in my wordpress but seo analyst show “No title Tag found error”?
- Why is wp_dropdown_categories not searching within the sub-categories in my custom taxonomy
- limit the number of searches
- How can I prevent the Search Results Page from changing title?
- Problem with site’s search results “Read More” link?
- Custom Post Search
- Make the title and […] clickable in result search
- Search multiple custom post types with tags
- wp_redirect and search engine bots
- Strip the + symbol from the_search_query
- Putting Text in the Search Box. eg- “Search My Site” [closed]
- How to remove search bar from the blog post
- Search and replace titles of posts with specific tags
- How do I turn this form into a search form? [closed]