Support

Account

Home Forums General Issues How to use ALT tags Reply To: How to use ALT tags

  • Hi Tracy,

    First of, get_the_title does not take any other parameter than the ID of the post in question..

    What you’re asking for in your first post is the alt text that you’ve put into the image editor in the media library. This is not really part of ACF but is a standard WP thing.

    So assuming that the field you’ve wrote in for each image is indeed the alt field your code should look something like this:

    This assumes that what you have created in ACF is an image field where you have set the return value to be the images id.

    
    <?php $imageID = get_field('THIS IS YOUR FIELD NAME FOR THE IMAGE'); ?>
    <?php $image = wp_get_attachment_image_src( $imageID, 'full' ); ?>
    <?php $alt_text = get_post_meta($imageID , '_wp_attachment_image_alt', true); ?>
    <img src="<?php echo $image[0]; ?>" alt="<?php echo $alt_text; ?>" />