Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

getting image alt text via ACF plugin in WordPress [closed]

You need to set your ACF field to return the image object instead of the URL. You can then use the following code to retrieve the image and alt text:

<?php $slideshow_image = get_field('slideshow_image');
// Check for alt text - if there isn't any, use the image title
$alt = ($slideshow_image['alt']?$slideshow_image['alt']:$slideshow_image['title']);
// Return full size image
$url = $slideshow_image['url']; ?>
<img src="https://wordpress.stackexchange.com/questions/161190/<?php echo $url; ?>" alt="<?php echo $alt; ?>" />

If you want to return the image at a different size, you can use the sizes array instead of the url:

// Return image thumbnail    
$url = $slideshow_image['sizes']['thumbnail'];

Documentation here under Customized display: http://www.advancedcustomfields.com/resources/image/

EDIT:

This solution works for ACF 3.3.7 and above only. Another method is to return the image/attachment ID, then use wp_get_attachment_image() to return the full image HTML.
Documentation here: http://codex.wordpress.org/Function_Reference/wp_get_attachment_image

Related Posts:

  1. How to change ID of an attachment in wp_posts and its related tables correctly?
  2. Regenerate images with automatic ALT and TITLE attributes
  3. Inserting HTML tag with ACF into shortcode
  4. Images under 1MB are not being compressed
  5. adding Adsense’s In-Article Ads between images of blog post
  6. Some images on WordPress site are suddenly gone
  7. WordPress built-in compression of images? How well does it compare to Photoshop or Shortpixel?
  8. Remove Keywords From Webpage But Still Use for SEO
  9. Get and Update Most Meta Value as an array in HTML form
  10. Same Title on two different post type with single custom taxonomy
  11. How to markup wordpress site using Schema.org?
  12. How should I force WordPress to give proper name for the uploading images?
  13. Image gallery plugin [closed]
  14. google conversion code
  15. How can I get WordPress to save comments in markdown format?
  16. Is Wrapping intval() Around esc_attr() Redundant for Escaping Input?
  17. Error shown for Trying to get property ‘roles’ of non-object in WordPress After Content for User Roles
  18. Hook into and send mail using WP Mail SMTP type plugin from HTML static front page?
  19. How to upload images to WP Panel keeping correct folder in FTP
  20. Can I use a plugin for a singular page on my website?
  21. Images not showing after changing wp-content folder name
  22. Preview featured image using frontend post plugin
  23. How to add an image from web-link?
  24. How can I implement an Add to Collection function on my Image Gallery to be downloaded later?
  25. How to Delete all Unused photos Function
  26. How to resize images due to container width automatically server side/without CSS
  27. Create digital-virtual-downloadable WooCommerce products from the frontend using Gravity Forms? [closed]
  28. Set featured image randomly from WordPress Database on post submission
  29. Howto accurately position images with maximum flexibility?
  30. qTranslate conflicts with SEO-plugins [closed]
  31. How Do I Figure Out What File(s) to Edit from Looking at the Source Code [closed]
  32. What is generating my meta og:description?
  33. Show an image in my header.php
  34. How to create a managed image repository in wordpress
  35. Assign / update custom field value for all posts (How can I assign only to posts without custom field value?)
  36. Creating custom HTML pages
  37. How to display the “ratingValue” and “ratingCount” values ​generated by the KK Star Ratings plugin into my page’s recipe ld+json schema
  38. How can I restrict image upload dimensions for non-admin WordPress users?
  39. Yoast SEO plugin “could detect no serious SEO problems” on dashboard
  40. get current date + 90 days and checking every day
  41. WooCommerce: Building a page with user input which is used to query order status and external API and return a result
  42. wp_generate_attachment_metadata is creating an empty array
  43. Force media library editor to overwrite the original filename?
  44. WordPress Sitemap including pages that aren’t there
  45. SEO Friendly URL on dynamic product page produced via shortcode
  46. install robots.txt to wordpress website admin
  47. Contact Form 7 Get Image Function [closed]
  48. How generate 200% image size and save with suffix @2x
  49. Load external images via proxy
  50. Bulk edit WP posts to update embeded images with new alt tags
  51. how to access all user dashboard on fronted page [closed]
  52. How can i get the post’s full html source by its ID?
  53. How to upload WordPress Images to remote web server and display those images in WordPress gallery [closed]
  54. Blog titles from WP blog on plain html site?
  55. Frontent user submit and view content [closed]
  56. html generated by theme exist but doesnt appear in browser
  57. How can I change the meta_key for a particular piece of information?
  58. How to insert HTML/JavaScript form into WordPress page? [closed]
  59. Add padding while generating thumbnail
  60. WordPress Post Visibility Options for Frontend
  61. Can we have an ‘Update metadata’ button in Image Gallery for all image instances?
  62. Retrieving Meta from Image Attachment
  63. Bulk update all posts from plugin settings screen
  64. WordPress putting “rn” in every line break?
  65. Add ALT attribute to Pin It Button image to pass HTML5 validation
  66. Make change in media library affect images in published articles
  67. plugin shortcode output
  68. Adding (image) caching to my Tumblr widget
  69. How to upload multiple files/images when developing a wordpress plugin?
  70. Image Manager Plugin [closed]
  71. Implementing an image hosting website using WordPress? [closed]
  72. Check if SEO plugin installed
  73. Bulk Image Upload And Rerrange Functionality
  74. Redirect to another page using contact form 7? [closed]
  75. How to include this jQuery File in wordpress?
  76. How to apply lazy loading in background images [closed]
  77. Show Sitename on Yoast SEO Title tag [closed]
  78. Meta box losing its value when scheduled post is published
  79. How to insert multiple postmeta values with one query?
  80. Woocommerce showing images blurry in description page
  81. Slider/text combination plugin
  82. Plugin to hide image in excerpt
  83. Help in using SEO Plugins: SEO Ultimate And Yoast SEO Plugin
  84. Mass SQL WordPress Meta Key deletion
  85. How to Loop Through all Posts and Count Attachments using Get Media Attachments
  86. Yoast SEO settings unavailable in an archive page from wordpress plugin
  87. Image change on hover
  88. How to write “alt” tag in image for wordpress code?
  89. Adding Static Image to WooCommerce Content-Single-Product template
  90. How do I get a post author’s image/avatar via RSS from another blog?
  91. Date format – Meta Box plugin
  92. In Woocommerce theme need to add custom external link [closed]
  93. Getting taxonomy images to display on single-post with their terms
  94. get meta value from database by post id
  95. How can I exclude a dynamic URL to show a popup created using ‘WordPress Popup’ plugin
  96. how to connect the author profile with google webmaster tools in multiuser blog?
  97. Photo Gallery Plugin and Touch Devices
  98. Yoast Force Rewrite Crashed Site [closed]
  99. Image crop, resize and compression plugin?
  100. how to insert a HTML form into a javascript popup?
Categories plugins Tags html, images, plugins, post-meta, seo
Why am I not able to save / update data in wp_editor?
Post/page without slug

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress