I am trying to query a list of child categories that are specific to a page. In other words, if I go to the page with the slug 'us-mid-western-tour' it queries the children categories of parent cat with ID 49 and if I go to 'us-western-tour' it gets ID 21 and so on.
Here is my code so far but it is not working. Can anybody steer me in the right direction?
$taxonomy = 'tournament_category';
$orderby = 'name';
$hierarchical = 1;
$child = if ( is_page('us-mid-western-tour')) {
echo '49';
} elseif ( is_page('us-western-tour')) {
echo '21';
}
;
$args = array(
'taxonomy' => $taxonomy,
'orderby' => $orderby,
'hierarchical' => $hierarchical,
'hide_empty' => 0,
'child_of' => $child,
Thanks D
use this
if ( is_page('us-mid-western-tour')) {
$child = '49';
} elseif ( is_page('us-western-tour')) {
$child = '21';
}
I hope it will help