Reputation: 31
In functions.php in wordpress, I'm using a function to display information, if, that post is Tagged with a certain Term, but within a custom Taxonomy "not a regular (tag)" The custom taxonomy will be "Special Info" or "special-info" as its slug
In my code below, its pretty straight forward, but how can i, "within the div" if the post has "special-info" taxonomy of "Block" Block being the Term of "Special Info" then Display "specified text here... " err i hope this makes sense
My Code function vision_contacts_description(){
if (has_term( 'colour-vision', 'brand' )) {
echo '<div class="repeat-descriptions" style=" padding-bottom: 10px;">Display Term within "Specified Custom Tax" Here.</div>' ;
}
}
add_action('woocommerce_product_thumbnails', 'vision_contacts_description', 25);
Upvotes: 0
Views: 210
Reputation: 1013
You can try and use *wp_get_post_term* function which will return all terms for your taxonomy (http://codex.wordpress.org/Function_Reference/wp_get_post_terms).
function someFuncName() {
global $post;
$terms = wp_get_post_term($post->ID, 'special-info');
foreach ($terms as $term) {
if ('Block' === $term['name']) {
//do something
break;
}
}
}
Hope this helps.
Upvotes: 1