Skip Navigation

[Resolved] Remove Captions in excerpts

This support ticket is created 6 years, 11 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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 3 replies, has 2 voices.

Last updated by Evan Seplow 6 years, 11 months ago.

Assisted by: Shane.

Author
Posts
#509889

Calling excerpts will also call the captions of images... so to remove them I used this in the past:

// Remove Captions in excerpts
// https://toolset.com/forums/topic/remove-captians-from-excerpts/#post-203640
add_filter('wpv_filter_post_excerpt', 'my_caption_func');
function my_caption_func($excerpt){
return $excerpt = preg_replace('#([[]caption)(.*)([[]/caption[]])#e', '', $excerpt);
}

But this is no longer working with newer version of PHP... can I request updated code from you for this?

#509965

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Scott,

Thank you for contacting our support forum.

Unfortunately not, we wouldn't be able to provide any support on this issue.

Thanks,
Shane

#510038

Wow,

That's a pretty cold response. Usually your team has been more helpful in helping to integrate simple functions that DON'T WORK from your plugins. As is evidenced from the initial help from Luo:

https://toolset.com/forums/topic/remove-captians-from-excerpts/#post-203640

Basically - your plugin in NOT FUNCTIONING CORRECTLY for a very standard situation.

#510202

Well,

I went down many paths of looking at Preg_Replace Callback, trying to figure it out... and many other replacements, plus creating my own excerpts and on and on... Some of them had many lines of code -- I finally figured out a ridiculously elegant solution. Here it is for all to use. All it does is pass the excerpt called by toolset through a shortcode stripper which is already built into wordpress core:

// Remove Captions in excerpts
add_filter('wpv_filter_post_excerpt', 'my_caption_func');
function my_caption_func($excerpt){
return $excerpt = strip_shortcodes( $excerpt );
}

Just add to your functions.php -- I hope this helps a lot of people out. If you add captions to your pictures, you'll definitely need it.

AS FOR THE SUPPORT ON THIS:
I'm really disappointed with the lack of support here.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.