Created
October 31, 2017 08:49
-
-
Save Tenderfeel/5bdc168ebb6093739984b9fde99456c4 to your computer and use it in GitHub Desktop.
WordpressでカテゴリーIDからカテゴリー名を得る
This file contains 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
<?php | |
$result = $wpdb->get_results($wpdb->prepare(" | |
SELECT name | |
FROM $wpdb->terms AS tm | |
JOIN $wpdb->term_taxonomy AS tmt | |
USING(term_id) | |
WHERE tmt.taxonomy = %s | |
AND term_id = %d | |
", 'category', $cat_id)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
get_resultsをget_colにしてもよい