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++;
}
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.
array('bw_filters')
at theget_terms
function?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?