[ad_1]
Hello, I’m trying to include the alt attribute in the<img> tags. I’m using the get_taxonomy_image function to fetch the image, but it doesn’t return the alt attribute with the tag. Can anyone show me how I might modify my code to include the alt tag for images? Here’s what I’m currently doing:
function wpc_elementor_shortcode_2($atts) {
if (!is_tag()) {
return; // Only run this in tag archives
}
$tag_id = get_queried_object()->term_id; // Get the current tag ID
$image_url = get_taxonomy_image($tag_id); // This function is supposed to fetch the image URL
if ($image_url) {
echo '<img src="' . $image_url . '" style="max-height:100px;">'; // Output the image
}
}
add_shortcode('tags_image_archive', 'wpc_elementor_shortcode_2');
