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?
- 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
- 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
- filter search custom field query
- Include custom taxonomy term in search
- How to set the seo title tag on a page by page basis?
- Add the post type to the title of the page
- WordPress search and date filter not working with custom post type
- Custom meta Title for custom post type archive from page
- 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
- find custom post type post by searching its custom field with my string
- Prevent A Specific Custom Post Type Showing In WP Search Results Page
- Hide custom post type from search based on custom taxonomy
- What is the correct term for a tool that filters content based on metadata?
- Pagination on search results page
- Sanitize title only if only custom post type
- Best way to create a search for custom post type by custom field values
- Multi Parameter search with custom post type category and tag
- CPT, meta-data, url parameter
- How to Implement Search Functionality?
- How to have multiple search result pages in wordpress with taxonomy terms listed
- Create a post automatically if search result has zero results
- Custom Post type doesn’t appear in search results
- filter the title changed also the page titles
- Custom Archive – hide posts until a search is made?
- Display result as “prefix+ID” and show in the search result as bookcode
- Error [Column ‘post_title’ cannot be null] when title is disabled for Custom post type
- Custom Post Search
- WP_Query with custom post type search showing all results every time
- 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
- Search page for custom post type
- Multiple search template with separate stylesheets
- Customising wordpress search and using $_GET[“s”]
- WordPress search results
- search this custom post type
- Drop Down Filter with CPT as Options for Search Form
- Searching Custom Posts content with JQuery
- WordPress search results grouped by post type
- Group search results by post type, but having a unique heading for each section?
- 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
- 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?