My website is an online magazine, so I have a custom function that creates a taxonomy (Volume/Issue) for Posts and Pages.
Each issue of the magazine has its own particular category (e.g. News, Alumni, Web Extras).
How do I get WordPress to programmatically display the appropriate populated categories for each Volume/Issue taxonomy?
For instance, in Issue v12n1, display a link to the News & Alumni archive page. In Issue v11n1, do the same for News & Web Extras (assuming there is no Alumni in v11n1 nor Web Extras in v12n1).
Is this even possible?
I've tried the get_terms
function, but I'm too limited as I'm only calling one category's parent, not the applicable taxonomy:
$volume = get_the_volume($post); //the custom function
$departments = get_terms('category', array(
'orderby' => 'ID',
'post_type' => 'post',
'volume' => $volume,
'category__not_in' => array(2, 9),
'order' => 'ASC',
'hide_empty' => true,
'parent' => '81',
));
if ( ! empty( $departments ) && ! is_wp_error( $departments ) ) {
$count = count( $departments );
$i = 0;
$department_list = '';
foreach ( $departments as $department ) {
$i++;
$department_list .= '<li><a href="' . get_term_link( $department ) . '" title="' . sprintf( __( 'View all post filed under %s', 'my_localization_domain' ), $department->name ) . '">' . $department->name . '</a></li>';
}
echo $department_list;
} ?>