I want to set post title for alt and title Attribute in this code
what should I do?
<?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;
?>
the_post_thumbnail()
will automatically include the image's alt text. You set it in the media library.