I want to amend the search so if say I have taxonomy called "author" and add a term of "Ian Rankin" to a post, if I search for "Ian Rankin", I want that post to come up. I guess at the moment it only searches titles and content. How can I make it search terms too?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
It could also be done by using MySQL's EXISTS function with a subquery that joins term_relationships with terms. I have created the following snippet and put it into functions.php:
You can alter the search query using filter hooks to join the taxonomy tables.
e.g. to also search on the 'author' taxonomy
First join the taxonomy tables
then find the search term in the taxonomy 'author'
and finally group the results by post id to avoid duplicate results because of the join