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
- CSS how to target the caption of one individual image?
- Customize all image captions
- show hide image script after 4 seconds [closed]
- Restricting users to view only media library items they have uploaded?
- How do I disable responsive images in WP 4.4?
- Filter to remove image dimension attributes?
- How to get a list of all the possible thumbnail sizes set within a theme
- How do I get the avatar URL instead of an HTML IMG tag when using get_avatar?
- Image Upload from URL
- Programmatically adding images to media library
- How do I delete all UNUSED images from my uploads directory?
- Set default image sizes in WordPress to hard crop
- Is it possible set a featured image with external image URL
- get attachment title based on attachment id
- Stop wordpress from hardcoding img width and height attributes
- Handle issues with change of image scaling (rounding) in 4.1 (WP Ticket #18532)
- Programmatically get images by URL and save in uploads folder
- Prevent WordPress from generating medium_large 768px size of image uploads?
- remove or update add_image_size
- How to extend the gallery block in Gutenberg?
- Image quality based on image size
- Function to get URL of original uploaded image – full size
- how to get original image using wp_get_attachment_image_src
- What is a good alternative to using $content_width for image optimization?
- get the attachement url for the medium sized image
- Can I attach image to post without adding it to post?
- Automatically replace original uploaded image with large image size
- WordPress crop tool greyed out
- How to scale up featured post thumbnail?
- Upload images to remote server
- Custom image size / thumbnail – Crop to aspect ratio even when source image is smaller than set dimensions
- Each custom image size in custom upload directory?
- Getting Images from theme’s directory in pages
- Set default image link target in Gutenberg image block
- Add an alignment option for images
- How to delete resized (cropped) image uploads and prevent future resizing?
- How to automatically add rounded corners to thumbnails?
- WordPress adding scaled images that don’t exist (1536×1536 and 2048×2048)
- Download an image from a webpage to the default uploads folder
- Add image size where largest possible proportional size is generated
- WP 4.4. responsive images browser choosing the “wrong” one
- After Moving a Site to Another Domain, All Images Are Lost
- Prevent WordPress from adding image’ title automatically
- Overide Gallery Default Link to Settings
- Retrieve featured image
- How to change image type for specific size?
- Add new image size to media uploader so users can insert into post?
- How to insert pictures without hard coded dimensions?
- Uploaded images don’t show in Media Library if there are special characters in IPTC Keywords
- How to modify image editor dialog options on WordPress?
- Why WordPress automatic cropping all my images?
- Allow contributor role to upload images and not edit already published articles
- What’s the proper way to find and remove duplicate images from posts and the media library?
- Remove images (files) that were generated when using add_image_size()
- get_post_gallery with Gutenberg
- Is there a hook which fires after all thumbnails are generated?
- Auto Add Image Title,Caption,Alt Text,Description while uploading Images in WordPress