I've been scratching my head all day with this one. I'm trying to use has_term
but it just won't work. I do get this notice but I'm not 100% sure it's related. I've also tried is_object_in_term()
but that doesn't seem to do anything in this case.
Notice: Undefined property:
stdClass::$object_id
in/wp-includes/taxonomy.php
on line 3613
if( has_term('past-attendees', 'speakercategory' ) ):
echo 'test';
endif;
if(is_object_in_term( $post->ID, 'speakercategory', 'past-attendees' ) ):
echo 'test';
endif;
wp_get_object_terms()
does return the term so I can't get my head around why the above two examples didn't work. Any ideas would be greatly appreciated.
$post
object into thehas_term
as the last parameter, do you get the correct result?$post
is not empty? To me looks like$post->ID
is null, that's why you are getting the notice message when usingis_object_in_term()
. Can you share the result forvar_export($post);
?