Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Custom search for custom post meta with pre_get_posts interferes with WP search

Create a another filter to remove post title and post content remove search terms
try this if this helpful for you

add_filter( 'posts_search', 'custom_post_search_author_do', 10, 2 );

function custom_post_search_author_do($search, $query ){
  if(  ! empty($search) 
       && $query->is_main_query() 
       && !is_admin() 
       && isset($_GET['search-type'])
       && $_GET['search-type'] == 'autor'
  )
  $search="";
  return $search;
}

Related Posts:

  1. How Do I Use WP_Query to Run This Database Query as Search Result?
  2. How to create a custom search for custom post type?
  3. what is the correct way to compare dates in a WP query_posts meta_query
  4. Advanced search form with filters for custom taxonomies and custom fields
  5. Correctly delete posts with meta and attachments [duplicate]
  6. Prevent pre_get_posts filter on specific post type
  7. Admin Area Custom Type Search By Meta Fields Without Title & Content
  8. Search multiple custom fields by using meta_query
  9. How do I Paginate Search Results for Custom Post Types?
  10. Search everything (posts, pages, tags, cpt, meta)
  11. filter search result with custom post type meta key
  12. WordPress Admin Panel search posts with custom post meta values along with title
  13. Search results ordered by custom post types are not grouped
  14. Can’t sort order of wp_query with 2 meta keys
  15. Having trouble with custom post type / meta box
  16. How can I include meta box content when searching?
  17. Building an Advanced Search (text, tags, category, custom fields) – Getting the wrong SQL query
  18. Custom Post Type, Saving Multiple Checkboxes
  19. How to create an advanced filter search?
  20. Multiple meta_values in the pre_get_posts filter?
  21. Custom post type search using $_SESSION and pre_get_posts
  22. changing meta value and meta key of price field
  23. WordPress sort search results by custom order
  24. Update postmeta Parent when post_status child change
  25. How do i search authors from search form using author’s name
  26. how to show records that don’t have custom meta value
  27. Prevent A Specific Custom Post Type Showing In WP Search Results Page
  28. Search CPT Title AND Meta
  29. How to have multiple search result pages in wordpress with taxonomy terms listed
  30. WordPress CPT Taxonomy Dashboard Search – How to include taxonomy in search?
  31. Search for custom field input of a custom post type in ajax live search
  32. How to Disable option of meta field if that option is selected for any other post in custom post type?
  33. Stored meta from attachment, video length?
  34. custom search results – order results differently by post type
  35. Custom Post Search
  36. pre_get_posts not firing at all
  37. Advanced search form with filters for custom taxonomies and custom fields
  38. Search for portfolio tags & mixing portfoliotags and post tags
  39. Displaying One Custom Post Type’s Content On Single Post of Another Custom Post Type
  40. Convert Custom Table Data Based Plugin To Be Searchable
  41. Blank search results on custom search
  42. Multi Parameter search with custom post type category and tag
  43. Add Class according to the order of appearance
  44. CPT, meta-data, url parameter
  45. Related posts meta_query CPT
  46. Need to have an archive widget which organizes and displays a custom post type using a custom date field
  47. Custom Content Type with No Page View
  48. Limit search field to just search a custom post type with custom fields
  49. Meta box with front-end styling
  50. Sanitaizing Select Optin For Custom Post Type Metabox in WP
  51. How can I get some of a posts meta data whilst it is still inserting?
  52. How to hide a custom field from admin?
  53. Get terms for a specfic post from multiple taxonomies in custom post type
  54. Custom post type tags not showing in search
  55. Problems making shortcode with custom post types and taxonomy
  56. custom comment fields on CPT
  57. How to retrive Custom Post Type Meta Fields in Custom WP_Query
  58. Advanced custom field – posted fields from custom post type
  59. Cannot Save MetaBox Data in Custom Post Type
  60. delete duplicate meta_value with same post_id
  61. HM CMB: Post Select Field for CPT ID
  62. CMB select with data from CPT
  63. pre_get_posts works in post type archive but not in single post
  64. Getting WordPress to store 0 values for custom post type meta
  65. Add Class After 4th Post
  66. $wpdb is queried but results don’t show
  67. updating one custom meta field only
  68. cannot achieve this structure (custom posts VS categories VS ??)
  69. Post visibility option to theme front-end for author to select?
  70. How to list posts by term (custom taxonomy)
  71. Add a class to post_class if more than one post shares same meta_value_num
  72. Query Multiple Custom Post Types & Exclude a Taxonomy Term
  73. Building a Data Intensive Website with WordPress
  74. Function to return values from metabox
  75. How to keep a record of changes to a custom field?
  76. Function to add custom HTML into head in custom post-type list page
  77. Is it possible to have hierarchical taxonomy and hierarchical custom post types in one permalink?
  78. Add a meta field to the list of results for a custom post type
  79. best way to use custom taxonomy, post type and meta in a job system
  80. Empty meta-box returns publishdate if no value is set?
  81. Custom taxonomy not saving correctly
  82. Say I have a tech blog, how best would I store technical specs for a phone, if i use custom post types
  83. Display future posts in search
  84. Redirecting search to specific templates with $_GET[“post_type”]
  85. What is the best way to manage small blocks of content on my home page?
  86. How to create Custom image post?
  87. Building tags and archive using meta from custom post type
  88. How to order custom posts by one of the custom fields value, ‘date’?
  89. One post auto attached to many another items
  90. How set template for “custom post type” individual post
  91. Problem Saving Custom Post Type Meta Values
  92. Filter search posts by post meta?
  93. Custom Meta Box with variable number of fields
  94. Modifying search results based on post_type
  95. how to use custom post types collectively integrated with each other
  96. Use Gravity Forms and a Shopping Cart for output to Freshbooks for an Estimate [closed]
  97. Custom Post Type Implementation
  98. Related “custom post type” using “custom taxonomy”
  99. Why doesnt my tag page populate with this custom post type?
  100. How do I “trash” a custom post type post while logged in as Admin
Categories custom-post-types Tags custom-post-types, customization, post-meta, pre-get-posts, search
SQL error #1062 – Duplicate entry ‘1’ for key ‘PRIMARY’ [closed]
WordPress File handle – fopen, fwrite not working with $.ajax or $.post Jquery

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress