Make WordPress Core

Opened 4 years ago

Last modified 4 years ago

#49877 new defect (bug)

Content enclosed by (content enclosing) shortcode gets stripped from excerpt

Reported by: mmwbadmin's profile mmwbadmin Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.4
Component: Shortcodes Keywords: dev-feedback
Focuses: Cc:


I’m using a plugin to create popups with information from Wikipedia by enclosing a term in shortcode. Like this

“Terwijl voormalig [wiki]Goldman Sachswiki bankier” (text in Gutenberg Paragraph Block, bold by me)

On a Blog Page and in a Latest Posts Block with non-manual excerpts the following output is rendered:

“Terwijl voormalig bankier”

Both the shortcode and the enclosed content are gone (due to wp_trim_excerpt? as called by the_excerpt() ). Whereas content enclosed in HTML tags stays in place.

The excerpt would preferably read:
“Terwijl voormalig Goldman Sachs bankier”

Is there a way to keep the content enclosed by (content enclosing) shortcode tags in the excerpt?

Using Wp 5.4 PHP 7.4 Theme Twenty-twenty (and Blocksy, Astra)

Imho I don’t see why you would want to loose your content (in enclosing shortcode tags) once an excerpt is created containing that content

Change History (6)

#1 @SergeyBiryukov
4 years ago

  • Keywords close reporter-feedback added

Hi there, welcome to WordPress Trac! Thanks for the report.

This sounds like an issue with the plugin you're using. Please note that this Trac is used for enhancements and bug reporting for the WordPress core software, not for individual support questions.

Could you provide the steps to reproduce the issue on a clean install?

I'd suggest trying the support forums to get help with your site:

#2 @mmwbadmin
4 years ago


Step 1. On a fresh install of WP5.4 + TwentyTwenty I added this to line 761 of functions.php:

function mmwb_shortcode( $atts, $content = null ) {
	return '<span style="color:red;" class="caption">' . $content . '</span>';
add_shortcode( 'mmwbt', 'mmwb_shortcode' );

Found in:

Step 2. Create a post and use shortcode within first 55 words. I used ….[mmwbt]schuldig bevondenmmwbt

Step 3. Create another post consisting of a Latest Posts Block with post content = excerpt

Already visible in the block is the missing result of the shortcode. Also the enclosed content is gone.

Step 4. Go to frontpage to see both posts and the difference.

Not sure what happens and whether it is caused bij plugin, theme or core

Last edited 4 years ago by mmwbadmin (previous) (diff)

#3 @mmwbadmin
4 years ago

  • Keywords close removed

#4 @mmwbadmin
4 years ago

  • Keywords reporter-feedback removed

Resembles ticket #25644

#5 @mmwbadmin
4 years ago

  • Keywords dev-feedback added

Same happens without any plugin.

#6 @mmwbadmin
4 years ago

Not plugin related.
Provided the steps to reproduce the issue on a clean install.

Note: See TracTickets for help on using tickets.