If you like my WordPress work, check out my new plugin, Bylines. Thanks!
Out of the box, WordPress’ search isn’t that great. It only returns posts based on a LIKE query against the post title or post content. Often, you’ll want it to match against other data associated with your post, possibly including the author, tags, post meta fields, etc. These queries can get complex to perform on the fly, however.
The following code snippet allows you to include posts by matching authors in your search results. We’re modifying any search queries to also include all posts whose author display name or user login matches the query. You can change this to be the author’s first name, last name, or other fields.
Updated May 17, 2012: Improved the user search so we don’t query for all users and search with PHP; instead, search against the users table.