Skip Navigation

[Résolu] Add code for image caption in theme template

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

This topic contains 5 réponses, has 2 voix.

Last updated by Ghennadi Il y a 7 années et 5 mois.

Assigned support staff: Ghennadi.

Auteur
Publications
#213074
caption.JPG

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.)

#213145

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.

#213147

Unfortunatelly not working. I see now 1 image (not the following 2) without the text.

#213152

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.

#213153
code.JPG
caption-2.JPG

Hi Ghennadi, Still not working good. See my screenshots.

#213334

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.

Le forum ‘Types Community Support’ est fermé à de nouveaux sujets et réponses.