I've been using the following code to get a template part based on the parent term. It was working fine until I updated WordPress to v4.4 earlier today. Since updating if there is also a child term selected it no longer works to bring in the template part.
Any ideas? I'm tearing my hair out.
<?php
$terms = get_the_terms( $post->id, 'type', array( 'parent' => 0 ) );
$terms_slugs = array();
foreach( $terms as $term ) {
$terms_slugs[] = $term->slug;
}
if( !empty($terms_slugs) ) :
get_template_part( 'blocks/block', array_pop($terms_slugs) );
else : endif;
?>
Edit: Solved it! Changing array_pop to array_shift. No idea what the difference is or why array_pop would suddenly stop working. Phew!
theme-name/blocks/block-termname
? How does the term-slug look, can you give us an example?get_the_terms()
? Withget_template_part()
? Can you narrow this down?