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:
- How to create a custom search for custom post type?
- Extending the search context in the admin list post screen
- Include custom taxonomy term in search
- Advanced search form with filters for custom taxonomies and custom fields
- Change “Enter Title Here” help text on a custom post type
- Creating a search form for custom fields
- Searching multiple custom post types and pages
- AJAX search on post pages by custom post type
- How can I change the admin search posts fields?
- How to make a WP_Query search with custom post types?
- How do I get a post (page or CPT) ID from a title or slug?
- group search results by post type?
- Limit the word count in the post title
- Development of a WordPress Search Plugin – Best Practices
- Is there a way to override the tag specified in header.php?
- Admin Area Custom Type Search By Meta Fields Without Title & Content
- Simple way to search custom-post types only
- Pushing a custom post type to the top of the search results
- Search multiple custom fields by using meta_query
- How do I Paginate Search Results for Custom Post Types?
- Custom post type admin search
- WordPress post sorting with AJAX
- Why have my custom post type searches stopped working after changing URLs / updating WordPress?
- Using standard search function with custom post type
- 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
- Set Custom Post Type title to the Post’s Date
- Change title in head on Archive page
- 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
- The right way to create a custom search page for complex custom post types
- Custom Taxonomies Terms as Post Title for Custom Post Types upon Publishing
- 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
- Set post title from two meta fields
- Search everything (posts, pages, tags, cpt, meta)
- How I check if the same post slug has not been used before publishing?
- Search Custom Post Type with all meta attached?
- WordPress Search documentation: how to improve search query using taxonomy terms, custom meta fields?
- filter search result with custom post type meta key
- Custom search for custom post type, custom meta and search fields
- Custom Post Type with Custom Title
- Include images from pages in wp search.php results in default wp search
- 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
- Backend search; include CPT meta?
- Custom Search form not working in localhost
- Custom Search | Wrong output & question
- Limit search form to 4 custom post types only
- Group search results by post type, but hide post types with no results
- Search results ordered by custom post types are not grouped
- pre_get_posts not firing at all
- multiple custom post type category selection search
- Custom Search Template for Custom Post Types
- Custom Search not working
- Search page for custom post type
- Custom post type blog pagination conflict
- Is it good practice to search for custom posts based on custom field values?
- Diffrent search templates for different post types
- Cannot get query var ‘post_type’ to work
- Multiple search template with separate stylesheets
- Advanced search form with filters for custom taxonomies and custom fields
- Problem with custom post type search
- Register a title automatically with a relationship field
- Archive custom template from search
- Searching for a single custom post type, buddypress
- admin search of pages returns custom post types
- Customising wordpress search and using $_GET[“s”]
- How do I do this?: If custom post type exists, echo it, else do not
- WordPress search results
- search this custom post type
- Why does ‘exclude_from_search’ exclude a custom post type from WP_Query?
- Drop Down Filter with CPT as Options for Search Form
- Searching Custom Posts content with JQuery
- Custom Field Search
- WordPress search results grouped by post type
- Custom post archive with search, is_search() is false?
- Why custom search engine only searches in post titles of custom posts?
- Custom post type split title, setup permalink accordingly
- How do I provide a search form for a specific post type, that is capable of searching within custom fields of the specified CPT?
- Group search results by post type, but having a unique heading for each section?
- Meta_query question
- How to exclude html tags and class on search
- Multiple search forms and respective results page templates?
- Fix Custom Post Type not appearing in search results?
- Search and filter terms of a custom post type only and display results
- Get a custom post type’s taxonomy type term names displayed as checkboxes and filter
- How to Display Content from Search URLs on Permanent URLs in WordPress?
- Exclude multiple custom post types from search
- Search for portfolio tags & mixing portfoliotags and post tags
- How can I retain get_post_type() in between consecutive searches after a search returns no results?
- How do I create a custom search function to only show contact information if they search for an exact unique identifier?