Hi!
This is what I have done:
<section id="app" class="detail [wpv-post-taxonomy type="artdesortes" format="slug" separator=" "]">
<section class="container pic-wrapper clearfix">
<ul class="owl-carousel pic-carousel">
<li class="item">
[types field='bild' size='full' alt='%%ALT%%' title='%%TITLE%% - %%DESCRIPTION%% - %%CAPTION%%' align='none' separator='</li><li class="item">']xx[/types]
</li>
</ul>
Works fine with owl slider with multiple images in a CPT.
Tell us what you are trying to do?
I need the %%CAPTION%% from every image for copyright purposes.
Either like this:
<img … data-caption=„%%CAPTION%%“>
or this:
<figure>
<img …>
<figcaption>%%CAPTION%%</figcaption>
</figure>
Is there any documentation that you are following?
I tryed this in multiple variations:
https://toolset.com/forums/topic/displaying-caption-from-media-post/
Is there a similar example that we can see?
What is the link to your site?
My site is non publicly online yet.
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Fabian,
Thank you for getting int ouch.
I'm not sure what you want to achieve with the caption.
Is it that you want to be able to add it here ?
<figcaption>%%CAPTION%%</figcaption>
Please provide a little bit more information on the exact setup and scenario that you want to use this in.
Thanks,
Shane
Dear Shane,
this is exactly, what I am tyring to to: I need to output the caption in any way, either als datacaption in the img-tag or as <figcaption>%%CAPTION%%</figcaption> outside the img-tag.
Thanks in advance.
Theo
Hi Theo,
Thanks for writing back.
Shane is on vacation and will be back next week, so I'll be following up on this ticket.
To fetch the caption text from an image/file, you can register a custom shortcode, that can accept its URL and then return the caption text.
Example:
add_shortcode( 'ts_caption_new', 'ts_caption_new_func');
function ts_caption_new_func($atts)
{
$url = $atts['url'];
$image_id = attachment_url_to_postid( $url );
if($image_id > 0) {
$image_caption = wp_get_attachment_caption($image_id);
}
if ($image_caption) {
return $image_caption;
}
}
Note: The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through active theme's "functions.php" file.
After that, you'll be able to call the caption text for each image/file from the repeating custom field like this:
( ref: https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-for-each )
[wpv-for-each field="wpcf-field-slug"]
URL: [types field='field-slug' output='raw'][/types]<br>
Caption: [ts_caption_new url="[types field='field-slug' output='raw'][/types]"]<hr>
[/wpv-for-each]
Please replace "field-slug" with the actual slug of your image/file field and you'll have the flexibility to build the HTML output as needed.
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar