Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

wp_get_attachment alt text

First of all you need to get attachment ID for getting alt text..

Use this code to get that,

$img_id = get_post_thumbnail_id(get_the_ID());

Now add your code,

<?php $alt_text = get_post_meta($img_id , '_wp_attachment_image_alt', true); ?>

<h1 class="entry-title"><?php echo $alt_text; ?></h1>
 
PREVIOUS NEXT
Tagged: #alt #text
ADD COMMENT
Topic
Name
9+9 =