function tbag_categories() {
global $wpdb;
$query = "SELECT DISTINCT $wpdb->term_taxonomy.term_id, $wpdb->term_taxonomy.taxonomy, $wpdb->terms.name FROM $wpdb->term_taxonomy
LEFT OUTER JOIN $wpdb->terms ON ($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id)
WHERE taxonomy = 'category' ORDER BY name ASC LIMIT 10";
$result = $wpdb->get_results($query);
foreach ($result as $category) {
$tbag_cat_id = $category->term_id;
$tbag_cat_name = $category->name;
$tbag_cat_url = get_category_link($category->term_id);
if ($category->term_id == '1') {
$output .= '';
} else {
$output .= '<a href="' . $tbag_cat_url . '" title="' . $tbag_cat_name . '">' . $tbag_cat_name . '</a>';
}
}
echo $output;
}
This produces a list of items:
FoodHotelCarPlane
I am trying to make it produce this:
Food, Hotel, Car, Plane
I want to use implode to add the coma and space, but I can not figure out where it will work in my code. I appreciate the help!