Hi, I want to show the caption of an image. I made a repeated field for images. This is the code in my single.php:
<?php echo types_render_field("foto", array("width"=>"306","resize"=>"crop","height"=>"226","align"=>"left","title"=>"")); ?>
How can I do this? (Look at the image in the attachment.)
Dear Dido,
Can you try this:
<?php echo img_caption_shortcode(array(), types_render_field("foto", array("width"=>"306","resize"=>"crop","height"=>"226","align"=>"left","title"=>""))); ?>
Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.
Regards,
Gen.
Unfortunatelly not working. I see now 1 image (not the following 2) without the text.
Dear Dido,
Sorry i forgot that it's repetitive.
Please try this:
$myvar = '[caption]'.types_render_field("foto", array("width"=>"306","resize"=>"crop","height"=>"226","align"=>"left","title"=>"", "separator"=>'[/caption][caption]')).'[/caption]';
echo do_shortcode($myvar);
Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.
Regards,
Gen.
Hi Ghennadi, Still not working good. See my screenshots.
Dear Dido,
Hi, this code will work.
$myvar = explode( ',', types_render_field("foto",
array("width"=>"306","resize"=>"crop","height"=>"226","align"=>"left","title"=>"",
"separator"=>',')));
if ( count($myvar) >0 ){
$images = '';
for ($i=0,$l=count($myvar);$i<$l;$i++){
$images .= '[caption]'.$myvar[$i].'[/caption]';
}
echo do_shortcode($images);
}
Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.
Regards,
Gen.