I want to show a category only if a (custom) post is in that category AND region = $name for that post.
So, e.g. I have a custom post (type "business") named "Mamma Mia" in child-category: "pizzerias" (and in parent-category "food"), and in region "Rotterdam" (custom taxonomy: "region", custom taxonomy term: "rotterdam").
=> display category "pizzerias" (and parent-category "food")
Only, I have no clue how to accomplish this. I'd appreciate any help on this puzzle.
<?php
// $filter = array('region'=>$name);
$categories = get_categories();
foreach ($categories as $cat)
{
if($cat->parent < 1)
{
$cat_name = $cat->cat_name;
$catid = get_cat_ID( $cat_name );
echo $cat_name. '<br/>';
$args=array(
'orderby' => 'name',
'order' => 'ASC',
'child_of' => $catid
);
$categories=get_categories($args);
foreach($categories as $category) {
echo '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a><br/>';
}
}
}
// print_r($categories);
?>
terms
that havebusiness
es assigned which are also assigned specificregion
?