how to set Alt & Title for featured image
-
hi
in this code, I want to add alt& title for featured imagesalt & title must be the post title
<?php if ( true == get_theme_mod( 'archive_featured_images', true ) ) : if ( has_post_thumbnail() && ( get_the_post_thumbnail() != '' ) ) : echo '<a class="featured-image" href="'. esc_url( get_permalink() ) .'" title="'. the_title_attribute( 'echo=0' ) .'">'; echo '<span itemprop="image" itemscope itemtype="https://schema.org/ImageObject">'; the_post_thumbnail( 'mudra-featured-image' ); $mudra_image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'mudra-featured-image' ); echo '<meta itemprop="url" content="' . esc_url( $mudra_image[0] ) . '">'; echo '<meta itemprop="width" content="' . esc_attr( $mudra_image[1] ) . '">'; echo '<meta itemprop="height" content="' . esc_attr( $mudra_image[2] ) . '">'; echo '</span>'; echo '</a>'; endif; endif;
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘how to set Alt & Title for featured image’ is closed to new replies.