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; ?>" />
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.