Hello
I'm trying to get bring in the ALT tag from an image. I'm using https://toolset.com/documentation/customizing-sites-using-php/functions/ and https://toolset.com/forums/topic/types_render_field-with-a-specific-post-id/ as a reference.
I've attached an image for you to see the results on the front end.
The issue - alt="%%ALT%%" does not bring in the alt text.
Specific line of code:
$shortcode = sprintf('[types field="litter-puppy-image" id="%1$s" size="medium" alt="%%ALT%%" output="html"]', $puppy->ID);
Below is the full code bit I"m working with
------------------
if(is_singular('litters')){
$litter_id = get_the_ID();
$puppies_in_litter_output = '';
$puppies_in_litter = toolset_get_related_posts( $litter_id, 'litter-puppies', array( 'query_by_role' => 'parent', 'return' => 'post_object' ) );
foreach ($puppies_in_litter as $puppy){
$puppy_full_name = get_post_meta($puppy->ID, 'wpcf-litter-puppy-name', true);
$puppy_nick_name = get_post_meta($puppy->ID, 'wpcf-litter-puppy-nickname', true);
$puppy_description = get_post_meta($puppy->ID, 'wpcf-litter-puppy-description', true);
$puppy_image_slug = get_post_meta($puppy->ID, 'wpcf-litter-puppy-image', true);
$shortcode = sprintf('[types field="litter-puppy-image" id="%1$s" size="medium" alt="%%ALT%%" output="html"]', $puppy->ID);
$thumbnail = do_shortcode($shortcode);
$puppies_in_litter_output .= sprintf('
Full Name: %1$s<div>Nickname: %2$s</div><div>Description: %3$s</div><div>Image: %4$s</div>
', $puppy_full_name, $puppy_nick_name, $puppy_description, $thumbnail);
}
if($puppies_in_litter_output!==''){
echo sprintf('<div class="et_pb_module et_pb_text et_pb_text_align_left et_pb_bg_layout_light ul-column-count-2"><div class="et_pb_text_inner">
</div></div>', $puppies_in_litter_output);
}
if($puppies_in_litter_output ==''){
echo sprintf('<div class="et_pb_module et_pb_text et_pb_text_align_left et_pb_bg_layout_light"><div class="et_pb_text_inner"><p class="text-center">Photos and Profiles Coming Soon!</p></div></div>');
}
}
--------
Is this something you can assist with?
Thank you!
Jules