Hello, not sure it is the right place to ask, but I step up anyway, just in case 😉
I need to wrap a php code for image that would fit my template’s scheme I’m using ACF since a long time, and the field I use is “image” returning and ID :
if ( get_post_meta(get_the_ID(), 'wpex_portfolio_post_details', true ) !=='' ) {
// display my image ;
echo '<div id="portfolio-post-details" class="clearfix">'.echo '<div id="portfolio-post-details" class="clearfix">'. "Price : ".get_post_meta($post->ID,'price',true)." €".'<br>' . wp_get_attachment_image(get_field('acf_poster_image'),'large'). '</div>';
} ?>
this code worlks fine
But I need to wrap the “acf_poster_image” so that the image displays the “alt” and the “title”. And I would like to display the image just like a standrd wordpress gallery, with a nice lightbox opening once you clic on it. I assume the class is “gallery-caption” (don’t want the texts to be displayed once it is full screen). I’ve produced some code inspired form the various FAQ and forum about that question, including from your site, but I still have errors. I’m a casual coder, so I’d be glad to have some help.
Many thanks
Hi @xzuxzulien,
Thanks for the post.
For you to get the title and alt from the image, you will need to change the return type to an object and change the display code since the ID return type cannot access the data in the image array.