I'm trying to get the terms of a taxonomy (kind) and the number of content they have but only for a specific category (get_parent_page_slug() = city name = category slug). This is what I have so far:
$args = array(
// 'taxonomy' => 'tipo',
'hide_empty' => 1,
);
$terms = get_terms('kind', $args);
//var_dump($terms);exit;
$count = count($terms);
echo '<ul>';
echo '<li><a href="' . get_bloginfo('url') . '/' . get_parent_page_slug() . '/' . $pagename . '/' . '" title="' . sprintf(__('View all post filed under %s', 'my_localization_domain'), $term->name) . '">Todos (' . $count . ')</a></li>';
foreach ($terms as $term) {
echo '<li><a href="' . get_bloginfo('url') . '/' . get_parent_page_slug() . '/' . $pagename . '/?tipo=' . $term->slug . '" title="' . sprintf(__('View all post filed under %s', 'my_localization_domain'), $term->name) . '">' . $term->name . ' ('. $term->count .')</a></li>';
}
echo '<ul>';
Just in case I clarify: I'm doing this in a page template. The results I expect are these:
Accommodation in City Name
- All (5)
- Hotel (1)
- Inn (2)
- Log cabin (1)
- Camping (1)
Thanks in advance