Created
July 17, 2012 13:46
-
-
Save ekka21/3129478 to your computer and use it in GitHub Desktop.
Wordpress: get term without links
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
/** | |
* Getting taxonomy from DB without having links | |
* @param $post_id | |
* @return string "tag1,tag3,tag4" | |
*/ | |
function go_get_terms($id){ | |
global $wpdb; | |
$q = 'SELECT * from wp_terms t LEFT JOIN wp_term_relationships r on r.term_taxonomy_id = t.term_id WHERE object_id = '.$id; | |
$rows = $wpdb->get_results($wpdb->prepare($q)); | |
$out = ""; | |
foreach($rows as $row) | |
{ | |
$out_str .= $row->name.','; | |
} | |
return substr($out_str,0,-1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment