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

Unable to show ACF’s Image Custom Field properly in Genesis Framework [closed]

Ok, so here’s the right answer, with the full code for an ACF Repeater Field:

$count = get_post_meta( get_the_ID(), 'items', true );

if ( $count ) {

    for ( $i = 0; $i < $count; $i++ ) {

        $item_100x100   = intval( get_post_meta( get_the_ID(), 'items_' . $i . '_item_100x100', true ) );
        $item_200x200   = intval( get_post_meta( get_the_ID(), 'items_' . $i . '_item_200x200', true ) );
        $item_300x300   = intval( get_post_meta( get_the_ID(), 'items_' . $i . '_item_300x300', true ) );

        if ( $item_100x100 ) {
            $image_id = wp_get_attachment_image_src( $item_100x100, 'full' );
        } elseif ( $item_200x200 ) {
            $image = wp_get_attachment_image_src( $item_200x200, 'full' );
        } elseif ( $item_300x300 ) {
            $image = wp_get_attachment_image_src( $item_300x300, 'full' );
        }

        if ( $image ) {
            echo '<a href="' . get_permalink() . '" rel="bookmark"><img src="' . $image[0] . '" alt="' . the_title_attribute( 'echo=0' ) . '">';

        }

    }

}

Or, instead the

echo

part, you can do:

printf( '<a href="https://wordpress.stackexchange.com/questions/261384/%s" rel="bookmark"><img src="https://wordpress.stackexchange.com/questions/261384/%s" alt="https://wordpress.stackexchange.com/questions/261384/%s" class="alignleft" /></a>', get_permalink(), $image[0], the_title_attribute( 'echo=0' ) );

You just have to change the ‘full’ to your desired image size.

UPDATE: As pointed out below by @bosco, wp_get_attachment_image will return an entire HTML element. We just want the URL for the image to be able to set the src attribute. Therefore, we’ll use wp_get_attachment_image_src in our code. I realize I was messing with the HTML.

Related Posts:

  1. Copying Custom Meta Values from existing post to a duplicate post
  2. Displaying Custom Fields on Post with Genesis Child Theme
  3. ACF: How to get the full field name (meta_key) by a field key?
  4. Get all the posts where meta field with multiple choice has several values checked
  5. WordPress creates new lines in postmeta table on post update
  6. How to get custom image field of specific post id
  7. Query Posts based on custom field value
  8. save all acf options in one meta_value [closed]
  9. Advanced Custom Fields: how do I check to see if a value is set in an field? [closed]
  10. Can I exclude a post by meta key using pre_get_posts function?
  11. Where are custom field values stored in the database
  12. Custom post meta field effect on the performance on the post
  13. How to get custom post meta using REST API
  14. Difference between meta keys with _ and without _ [duplicate]
  15. Orderby meta_value only returns posts that have existing meta_key
  16. What is the index [0] for on post meta fields?
  17. What is “meta_input” parameter in wp_insert_post() used for?
  18. How to enable revisions for post meta data?
  19. The “_encloseme” Meta-Key Conundrum
  20. Best way to programmatically remove a category/term from a post
  21. Using get_post_meta with new_to_publish
  22. Advanced Custom Fields – Get custom fields from parent page
  23. Add custom field to the archive page?
  24. Matching Serialized Arrays with meta_query
  25. Custom field metabox not showing in back-end
  26. So much data in postmeta
  27. Can I count the number of users matching a value in a multiple value key?
  28. How to position a custom field before the editor
  29. When using add_post_meta and update_post_meta, is there any way to give the individual arrays keys?
  30. How to hide meta box values from custom fields list?
  31. Auto sort the wp-admin post list by a meta key
  32. get_post_meta() unserialize issue – returns boolean(false)
  33. Display post_object content using Advanced Custom Fields plugin
  34. What is the advantage of the wp_options design pattern?
  35. Remove old custom field after import
  36. Storing meta fields multiple times OR once with multi dimensional array?
  37. Unable to get Preview of Uploaded image within a Custom Meta box
  38. Allow user to create instances of custom field
  39. display specific custom fields
  40. Is there a hook / action that is triggered when adding or removing a post thumbnail?
  41. Meta keywords and descriptions plugin for manually editing meta for each page/post
  42. Retrieve custom fields on Categories, using WP-API
  43. passing argument to get_template_part() or a better way to code
  44. Is it possible to store arrays in a custom field?
  45. Get updated meta data after save_post hook
  46. Multiple meta values for same meta_key adding on “Preview Changes” hit but not on saving or updating post
  47. Save HTML formatted data to post meta using add_post_meta()
  48. importing data from non-wordpress mysql db
  49. Order by custom field date?
  50. Create meta boxes that don’t show in custom fields
  51. Transients vs CRON +Custom Fields: Caching Data Per Post
  52. Unable to save datetime custom meta field using update_post_meta() function
  53. Up/Down voting system for WordPress
  54. Change content before writing to database
  55. post meta data clearing on autosave
  56. Create custom field on post draft or publish?
  57. Display info from custom fields in all images’ HTML
  58. Order Custom post type loop by custom field (datepicker)
  59. Ordering posts by anniversary using only day and month
  60. get_post_meta fields don’t show up on posts page
  61. Using Custom Function With Advanced Custom Fields
  62. Update meta values with AJAX
  63. How to break meta values into different items and avoid duplicates?
  64. automatically set “Featured Image” the same as the og:i that is set in a custom field
  65. copy attachments to another post type and change attachment url
  66. Cannot edit post meta fields with rest API
  67. ajax delete value from custom field array
  68. Problem with adding exta field in metabox in custom post type
  69. Save attachment custom fields on front end
  70. How to use pagination with get_post_meta
  71. Add a post meta key and value only if it does not exist on the post
  72. Move value of one custom field to another
  73. Order posts according to user defined order for meta values?
  74. Calculate the sum of certain the_sub_fields
  75. Displaying posts with only upcoming dates according their custom field date value
  76. Custom fields to save multiple values
  77. Custom fields: In what order are they saved into the DB?
  78. Function to change meta value in database for each post
  79. get_post_meta not working inside loop
  80. ACF Upload Image in repeater from front-end with custom form? – add_post_meta()
  81. Get a post_id where meta_value equals something in a serialized meta_value field
  82. Get aggregate list of all custom fields for entire blog
  83. Transition from (classical) serialized custom meta field to (gutenberg) rest enabled meta
  84. Login & Register & Custom details WITHOUT plugin
  85. Custom field value based on other custom field values
  86. Send Multiple Custom Field Values Through the URL
  87. wp_handle_upload error “Specified file failed upload test” but still creates attachment?
  88. ACF won’t load from a custom JSON location
  89. How to save a ToggleControl value in a meta field?
  90. Which is best in the following scenario : post_meta vs custom table vs parent/child posts
  91. Saving custom image meta fields
  92. Author Page Custom Query WHERE author OR [post meta value] OR [post meta value]
  93. How to display Meta Field Value?
  94. MySQL query to set wp_postmeta using term_taxonomy_id value
  95. How to Validate Post Meta type/extension (Video File Image File etc)
  96. Get all meta keys assigned to a post type
  97. Show ACF fields only on certain page in the backend
  98. using multiple meta_key and meta_value in query_posts
  99. Update posts after populating ACF field value [closed]
  100. Custom Meta Box not Saving in Posts with Gutenberg Editor
Categories custom-field Tags advanced-custom-fields, custom-field, genesis-theme-framework, post-meta
How to exclude shortcode from specific page IDs if it’s set to global
Build on same WordPress or different install?

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