I didn’t test the code below, but I guess it works.
/**
* Search SQL filter for matching against post title only.
*/
function __search_by_title_only( $search, &$wp_query )
{
/*my solution */
if($_GET['post_type'] != 'attorney' )
return $search;
/*my solution*/
//please copy the rest of the code from the link below
}
add_filter( 'posts_search', '__search_by_title_only', 500, 2 );
Related Posts:
- Advanced search form with filters for custom taxonomies and custom fields
- How to make a WP_Query search with custom post types?
- Is there a way to override the tag specified in header.php?
- Search multiple custom fields by using meta_query
- How do I Paginate Search Results for Custom Post Types?
- WordPress post sorting with AJAX
- Why have my custom post type searches stopped working after changing URLs / updating WordPress?
- Search that will look in custom field, post title and post content
- How to correctly get post type in a the_title filter
- Have different search results template depending of custom post type searched
- How to hook into the CPT’s title placeholder?
- title_save_pre on post publish
- Returning search results by relevance, including Custom Post Types
- How to replicate some of Drupal Views functionality in WordPress?
- How To Set Custom Post Type Title Without Supports
- Seperating Custom Post Search Results
- Exclude from search all custom posts which are NOT in a taxonomy term
- Exclude a term of a taxonomy with a custom post type in a search
- How I check if the same post slug has not been used before publishing?
- Separating Search Results By Post Type
- How Do I Use WP_Query to Run This Database Query as Search Result?
- Setting a title on a Custom Post Type that doesn’t support titles
- Custom Post Types: pretty search URLs and has_archive
- WordPress Admin Panel search posts with custom post meta values along with title
- Custom Search form not working in localhost
- Using a Custom Field instead of original title field but only for Custom Post Type
- Is there An Input Checkbox Option That Works like `wp_dropdown_categories()` To Use In A WP Search Form?
- Include different loop templates in search query
- get_page_by_title() not returning anything [closed]
- Custom Post Types: Custom columns with Title submenu?
- Search tags in CPTs
- Set meta_query only for specific post type
- Posts created in a Custom Post Type are lost if published without a title
- Custom Post Type not appearing in website search
- How to filter out post type meta?
- Updating post title using wp_update_post
- CPT Search Form with Taxonomy filter & Or
- Keyword search limited to specific post type filtered by multiple custom taxonomies?
- Custom search for custom post meta with pre_get_posts interferes with WP search
- How to use the Display Name as the post title in a custom post type?
- Including Custom Meta with posts_where query
- I did group my search results by post type, but how can i give each of them its own order?
- Add acf field in title (admin table)
- How can I run this code once so that my generated post title doesn’t keep changing on publish/update?
- Set a maxlength for the title input in a custom post type
- WordPress sort search results by custom order
- Pretty URL for custom search for custom post type
- Add post location with mile radius allowing search
- Include custom post type content in search
- Get post count for search result based on post type
- search suggest – filter post type
- Searching Custom Post Types
- How do i search authors from search form using author’s name
- Searching Custom Fields
- How to set the seo title tag on a page by page basis?
- Can NOT search my custom post type?
- Custom post_type search pages
- WordPress search and date filter not working with custom post type
- Custom filter for main search: how to exclude specific post_type from search results
- Add custom attributes to a post
- Display an icon based on post type
- how to get this tax_query working?
- Custom Taxonomy Search result page
- How to group search results by post type and only if post type result is not empty?
- find custom post type post by searching its custom field with my string
- Category Search / Custom Post Type search on my website. Custom Post Types that are “page-like”?
- What is the correct term for a tool that filters content based on metadata?
- Ideas on how to organize a project [closed]
- Filtering custom posts by custom fields (ACF) [closed]
- CPT, meta-data, url parameter
- Search CPT Title AND Meta
- Modifying search results based on post_type
- Auto Generate Post Title from 2 Custom Fields
- How to Implement Search Functionality?
- Change search query in wordpress custom post type
- Create a post automatically if search result has zero results
- Want to add new label in new post
- Search only one custom post type
- Query first and last name from custom post type
- Custom Archive – hide posts until a search is made?
- Display result as “prefix+ID” and show in the search result as bookcode
- Include images from pages in wp search.php results in default wp search
- custom search results – order results differently by post type
- Error [Column ‘post_title’ cannot be null] when title is disabled for Custom post type
- Post search not looking at post title since 4.4.2 upgrade
- Custom Post Search
- Search form to find custom meta box generated data
- 404 error Custom search results page for custom post types with friendly URL
- multiple custom post type category selection search
- Custom Search Template for Custom Post Types
- Custom Search not working
- Search page for custom post type
- Is it good practice to search for custom posts based on custom field values?
- Cannot get query var ‘post_type’ to work
- Register a title automatically with a relationship field
- Archive custom template from search
- Customising wordpress search and using $_GET[“s”]
- search this custom post type
- Why custom search engine only searches in post titles of custom posts?
- Meta_query question