Last active
August 29, 2015 13:56
-
-
Save annalinneajohansson/99809b98dacf8d2344e9 to your computer and use it in GitHub Desktop.
SQL SELECT to match a searchterm in wp_terms but only from a specific taxonomy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * FROM $termstable AS terms | |
JOIN ".$wpdb->prefix."term_taxonomy AS termtax ON terms.term_id = termtax.term_id | |
WHERE termtax.taxonomy = '$taxonomy' | |
AND terms.name LIKE '%$searchterm%' COLLATE utf8_swedish_ci | |
ORDER BY termtax.count DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment