Skip Navigation

[Resolved] Featured Image with caption

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to display the featured image with its caption.

Solution: Use the featured image shortcode twice, once for the image and again for the shortcode, like this:

[wpv-post-featured-image size="medium"]<br />
[wpv-post-featured-image output="caption"]

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#vf-153425

This support ticket is created 6 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 8.09 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 7 replies, has 3 voices.

Last updated by BarbaraD9652 6 years, 3 months ago.

Assisted by: Christian Cox.

Author
Posts
#1072671

Tell us what you are trying to do?
Are you able to control where the featured image is placed on a page?

#1072681

If not how can we display the caption for an uploaded image, set up as a custom field?

#1073368

1. Yes, you can control where to display a Featured Image in Toolset.
You would use the ShortCode wpv-post-featured-image for it:
https://toolset.com/documentation/user-guides/views-shortcodes/#vf-153425

You can place this anywhere in a Post Body or Content Template for example.

Remember that Themes often already output the Featured Image along with the title, the post body and other things.
Toolset, natively, only replaces the content.

This means, if you insert a featured image in a content, and your theme as well outputs it, and offers no settings to disable that, the featured image would be visible twice.

2. Captions are not custom fields and cannot be set up like that.
An image, in WordPress, will have a caption that is stored as a post excerpt of the attachment post.
So, theoretically you can output any caption by displaying the Attachment posts excerpt.
For that you would need to pass the ID to the precise ShortCode for the excerpt:
[wpv-post-excerpt item="9"] //where 9 is the ID of the attachment post.

Or, if you upload images with our Fields you can simply use the ShortCode to insert it.
There you can use the native WordPress methods to display the data belonging to the attachment.
For example for the alt and title attributes, you can also use placeholders to output the values of standard image fields added in WordPress: %%TITLE%%, %%ALT%%, %%CAPTION %%, and %%DESCRIPTION%%.

However, I may derail, as probably with the first answer above the issue you report is solved?

BTW; for the featured image, you can display the caption only, like this:
[wpv-post-featured-image output="caption"]

🙂

#1077591
Screen Shot 2018-08-08 at 3.05.42 PM.png

HI - Thanks for your help.

The client wants to use the Featured Image.

I inserted the ShortCode but if you notice in the uploaded image the image is on the left and the caption on the right. Both need to be on the right. When I disabled the setting: Disable Featured Image, the image disappeared but the caption remained.

Here is a link to the page:
hidden link

Here is our code:

<div class="container">
<div class="row">
<div class="col-sm-7">
<h3 style="color: #930e12;font-weight: 600;">[wpv-post-title]</h3>
<p>[wpv-post-body view_template="None"]</p>
</div>
<div class="col-sm-1"></div>
<div class="col-sm-4">
<div style="margin:0px 0 18px;">[wpv-post-featured-image size="full" output="caption"]</div>
<div style="margin:0px 0 18px;">[wpv-conditional if="( $(wpcf-company-logo) ne '' )"][types field='company-logo' alt='%%ALT%%' title='%%TITLE%%' size='full' align='none'][/types][/wpv-conditional]</div>
<p align="left">Address:<br />
[types field='address'][/types]<br />
[types field='city'][/types] [types field='state'][/types] [types field='zip-code'][/types]<br />
[types field='country'][/types]</p>
<p>Phone:<br />
[types field='phone'][/types]</p>
<p>Website:<br />
[types field='website' no_protocol='true' target='_blank'][/types]</p>
<p>[wpv-conditional if="( $(wpcf-contact-1) ne '' )"]Contact:<br />
[types field='contact-1'][/types][/wpv-conditional]<br />
[wpv-conditional if="( $(wpcf-contact-1-title) ne '' )"][types field='contact-1-title'][/types][/wpv-conditional]<br />
[types field='contact-1-email'][/types]<br />
[types field='contact-1-phone'][/types]</p>
<p>[wpv-conditional if="( $(wpcf-contact-2) ne '' )"][types field='contact-2'][/types]<br />
[types field='contact-2-title'][/types]<br />
[types field='contact-2-email'][/types]<br />
[types field='contact-2-phone'][/types]</p>
<p>[/wpv-conditional]<br />
[wpv-conditional if="( $(wpcf-contact-3) ne '' )"][types field='contact-3'][/types]<br />
[types field='contact-3-title'][/types]<br />
[types field='contact-3-email'][/types]<br />
[types field='contact-3-phone'][/types][/wpv-conditional]</p>
<p>Capabilities:<br />
[wpv-post-taxonomy type="type-of-optic" format="name" separator=" | "]<br />
[wpv-post-taxonomy type="type-of-service" format="name" separator=" | "]<br />
[wpv-post-taxonomy type="type-of-material" format="name" separator=" | "]<br />
[wpv-post-taxonomy type="type-of-research-interest" format="name" separator=" | "]</div>
</div>
</div>

#1077662

I made some changes.
The line is now

<div style="margin:10px 0px;">[wpv-post-featured-image size="medium"]</div>

The image shows up but not the caption. If I add

output="caption"

then just the caption appears. I tried variations of

output="img caption"

but that only provides a line that indicates where the image is located.

link to page:
hidden link

any ideas?

#1077676

I think changing the image size to medium aligned it to the right. But I also had to check "Disabled Featured Image" or it would show up twice. Once on each side.

#1078477

Hi, it sounds like you would like to show both the image and the caption. Can you use the shortcode twice like this:

[wpv-post-featured-image size="medium"]<br />
[wpv-post-featured-image output="caption"]
#1078588

Thank you Christian - Simple but effective!!!