Try:
global $post; return is_single() && is_object_in_taxonomy($post, ‘taxonomy x’);
(from wordpress/wp-includes/taxonomy.php)
i’ve not tried it, but the comments in that file imply it should work.
heya alanft – thanks for the response
that seems to definitely be on the right path!
when i add that full line to the widget_logic field, it works perfectly on single pages within the taxonomy. however, it appears to also be showing up on single pages NOT within the taxonomy. as if it were only recognizing the first portion (is single)
did i miss a step…?
i don’t think i understand taxonomies very well – it looks to me like they apply to all posts (of a particular type) or not. but when you say ‘show only on posts that are within a taxonomy’ that doesn’t seem to match up with that. sorry
much appreciated, alanft, all the same! just to be sure i used your code as you intended, let me detail what I did more accurately. I added the following code to the widget logic field:
global $post; return is_single() && is_object_in_taxonomy($post, ‘sports’);
where “sports” is the taxonomy, with groups like “baseball” “football” and “basketball” beneath it. (did i do that correctly, as you intended…?)
as said, that worked perfectly for any post within the animals taxonomy (all posts under “baseball”, all posts under “football”, etc, etc.). unfortunately, the problem is, the widget still appeared on single pages outside of any taxonomy (e.g.; a post about vacuum cleaners)