I just noticed on my site that the custom taxonomy terms are no longer out putting. I am only guessing that it's happened since the 4.2 update. Here is the php:

$terms = get_the_terms( $post->ID , 'bw_filters' );
$genres = get_terms( 'bw_filters' , array( 'child_of' => 5   ) );
$terms_ids = array();
$genres_ids = array();
$output_terms = array();
foreach( $terms as $term ){
    $terms_ids[ $term->term_id ] = $term->term_id;
foreach( $genres as $term ){
    $genres_ids[ $term->term_id ] = $term->term_id;
foreach( $terms_ids as $term ){
    if( in_array( $term , $genres_ids ) ){
        $output_terms[] = $terms[ $term ];

$count = count( $output_terms );
$i = 1;
foreach( $output_terms as $term ){
    echo $term->name;
    if( $i < $count ){
        echo ', ';

I had someone else write this a long time ago, so I may not have answers to all questions about the code snippet.

I suspect it's the get_terms function that's no longer working as it should. Previously, this code worked fine, and it would display children of ID 5. Not it outputs nothing at all. Just blank.

Any ideas are helpful. Thanks.

  • Did you try passing 'bw_filters' as array('bw_filters') at the get_terms function?
    – fischi
    May 6, 2015 at 19:58
  • get_terms just accepts another argument for the second parameter now, nothing in it changed that would affect this code, there is almost certainly another issue. @fischi a string should work just as well as an array, but it's worth a shot. MarkC, can you verify that both $terms and $genres are populated with values? May 7, 2015 at 4:15

1 Answer 1


I've got this fixed now. Managed to talk with my old developer and he added this:

$termsById = array();
foreach ($terms as $t) {
    $termsById[$t->term_id] = $t;

I had to add this new variable where $terms was previously used on line 14.

Thanks for your help everyone, I appreciate the effort.

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.