• Resolved samseurynck

    (@samseurynck)


    Hey!

    I’m attempting to show the values of two custom taxonomies while looping through custom post types. I’ve done it successfully for one of the two using this code:

    $topic = get_the_terms($post->ID,array('taxonomy' => 'topic'));
    if( !empty($topic) ):
    	foreach($topic as $topics) {
    		$color = get_field('topic-color', 'topic' . '_' . $topics->term_id);
    		echo '<a class="current-research-button" style="border-color:' . $color . ';"href="' . get_category_link($topics->term_id) . '">' . $topics->name . '</a>';
    } endif; ?>

    If I add another variable for a second taxonomy, I get this error:

    Warning: Illegal offset type in isset or empty in /Users/hobbes/Local Sites/detroitpeer/app/public/wp-includes/taxonomy.php on line 340

    If I comment out the first variable ($topic) then the error goes away and the second taxonomy loop runs just fine.

    What could be causing this?

    The page I need help with: [log in to see the link]

Viewing 16 replies (of 16 total)
Viewing 16 replies (of 16 total)
  • The topic ‘‘llegal offset type in isset or empty in …on line 340’’ is closed to new replies.