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 ) {
                  $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;
            } ?>

1 Answer 1


It's hard to understand how you use your taxonomy and where you want to display it.

Does your posts have a custom taxonomy and you want to display it there? Or you have some page, like /issues/, with a list of posts that linked to a certain issue number and grouped some how?

So, if you want to retrieve a categories based on custom taxonomy, you could use this code:

In your functions.php define this function:

function my_custom_function() {
    global $post;
    $result = get_the_term_list( $post->ID, 'people', '<span>', '&nbsp;', '</span>');
    echo $result;

Then in your loop inside a theme files just call it.


<?php my_custom_function(); ?>

It's important to understand, that we don't know your implementation details, and you should provide a Post Id by yourself. Through, it's a working, tested example which retrieves every category for a given post.

And I think you would be easier to just retrieve categories.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.