I realize improving WordPress’s search function is a huge can of worms, but the ONLY additional thing I need it to do is to show results when I search for an author’s name.
For example, if we have an author named Katie Johnson, and I search for Katie, I get results where her name is listed in the CONTENT, but not results that she POSTED.
This seems like a simple problem, and yet I haven’t yet found a solution to it.
Thanks.
Maybe you can try adding your condition directly in the query string, using something like this
I couldn’t get either of those answers to work for me, but I found this:
https://danielbachhuber.com/2012/02/07/include-posts-by-matching-authors-in-your-search-results/
Worked without any edits. Here’s the code incase the link is ever out of date:
Improving on @hacksy’s answer, I have used the same block of code but changing it to successfully search company name using the WP Job Manager plugin.
What it does is search the
meta_key
column of thefirst_name
,last_name
, and_company_name
values then check for a value under themeta_value
to see if it matches the search query. If a user_id is found, the SQL search query is appended to search for the post_author ID and if the slug of the company is found under thepost_name
column.