It turned out that the method called strip_tags(preg_replace(" (\[.*?\])", '', $output))
before strip_shortcodes($output)
, which caused aforementioned issue, since the code removed shortcode in square brackets, but retained contained image captions.
I could fix it by swapping the two method calls like this:
$output = get_the_content();
$output = strip_shortcodes($output); // Strip WordPress shortcodes first!
$output = strip_tags(preg_replace(" (\[.*?\])", '', $output));
Related Posts:
- Get Image Description
- How to have different captions for same image, for galleries?
- Featured image shortcode
- How to wrap WordPress image captions inside H2, H3 tags?
- Is there a way to define a default caption to all uploaded images
- How to add a link in a image’s caption?
- Alter media caption/description conflict in WordPress?
- How to display a shortcode caption somewhere other than the_content
- Caption in Page adding unwanted 10px to width
- add data-attribute to all images inside the_content()
- Adjust image caption within visal editor
- Drag images with caption in WP editor
- Different captions for the same image in multiple galleries. Edit Image in Gallery locally
- Include captions
- HTML tags in WordPress image caption
- Add attribute to caption shortcode from custom attachment field
- Removing height and width from images with a caption
- Extracting gallery images in WordPress 3.5 on index.php
- Include caption underneath post images
- Turn off image captions in gallery view?
- Move Image Captions Inside Link ( tag) if Added
- How to add custom classes to figure element only if image has caption?
- Replace image caption with its title and description
- the_content not showing responsive image attributes srcset or sizes
- Random home page background images with caption text
- How to edit caption for images and exclude it from excerption query?
- Place image caption outside of figure tag (Gutenburg Image Markup)
- How to remove image size inline style in article and include caption
- How to join Caption AND Description Meta Fields as one combined-caption in Image Block
- How to get title of images in post content
- how automatically show the image title before the image caption/description in a wordpress gallery?
- How to Display Image Caption but Not Alt Text
- How to auto add image caption from image alt?
- Is there a way to create referable automatic numbering in image captions?
- Why do images inserted in the post content via the_content() go off the max-width?
- Displaying “alt” attribute text as captions?
- How to best adjust images to a max content width of 490px?
- page displaying media caption shortcodes
- Removing image dimensions from `the_content`
- How to add a credit line to a photo caption
- Show uploaded images in full size
- Wrap a post image with a div if it doesn’t have a caption
- How to access & display images from a post without textual content ( and vice versa) according to best wordpress practices
- How do I disable responsive images in WP 4.4?
- After Moving a Site to Another Domain, All Images Are Lost
- How to find attachment by it’s name?
- Change html structure of all img tags in WordPress
- How to disable “insert into post” only when selecting the Featured Image?
- How can I add the “Use as featured image” to a custom metabox?
- How to increase media image scale limit?
- Dynamic-Image-Resize Plugin does not output anything
- Cannot access the thumbnails of attachment images… Cannot find the reason
- How to place an image into header.php? [closed]
- Uploading an image as featured image from frontend form
- @wordpress/create-block image url in css
- How does WordPress work out the srcsets?
- How to include a picture in a blog post such that it will show in Facebook?
- Remove ‘wp-content/themes/themename/’ from Image path
- Why html tags are being appended to my pictures?
- wordpress media library shows empty images
- How to change the target size of images clicked on in WordPress standard gallery
- Mobile Featured Image Bug
- Imagick vs GD colour issues on image uploads
- How to add image and featured image to post by WP REST API
- Jetpack’s photon causes local site to try and serve images from WordPress CDN [closed]
- How to stop wordpress always displaying full-res images
- WordPress PNG compression issue
- Fallback image size when using wp_get_attachment_image_src / full size compressed image
- Rewrite all article pictures to link to file
- Upload box media size not working
- Featured images disappear after DB export/import?
- Where is the right place to store custom images?
- Images give 404 after changing default domain
- Load Gallery Images with Title on Homepage BX Slider
- Resize images in batch
- Advice on image heavy site, compression and slow page loads
- Blurry images when using add_image_size with crop
- Auto delete pictures in media library by age
- Shortcode function doesnt work without caption
- How to get image URL from media_sideload_image?
- Can’t get text to wrap around image
- Allow SVG in WP step by step
- Serve different images per screen size and cache possible?
- Auto-crop width, not height
- Convert featured images into “product images”
- Having an issue in compressing Images in wordpress site
- Word press cutting sliding images – not displaying the entire image
- Image links broken / “DNS Update Required” message
- Convert multiple image blocks to gallery block in Gutenberg?
- Image sizes reset when changing theme
- How to get featured image of last post in a category?
- After moving a site to new hosting, not all images are showing in media library
- Custom Background for each page and post
- How can the alt be added to this wooCommerce category image?
- Delete images of a particular size
- Images not rendering
- Add category description to list of category with taxonomy image
- How do I get the URL of only the first picture in a WordPress post?
- Images getting corrupt automatically
- Thumbnail size keeps resetting automatically