Image alt tag
-
Hello, I’m trying to include the
alt
attribute in the<img>
tags. I’m using theget_taxonomy_image
function to fetch the image, but it doesn’t return thealt
attribute with the tag. Can anyone show me how I might modify my code to include thealt
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');
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Image alt tag’ is closed to new replies.