Tutorials for web designers and developers
Tutorials for Developers_

Fixed: Shortcode appearing in excerpts – WordPress

Wordpress shortcode appearing in excerpts on archive page

Sometimes, shortcodes appear in the post excerpts on the archive page of WordPress site. This is a common issue with excerpts in WordPress due to theme or plugin issues. This can be very easily fixed.

Remember: These methods will work only if the shortcodes are registered with WordPress. If you are trying to remove shortcodes those got remained after deactivation and deleting the plugin then this will not work, because now those shortcodes are not shortcodes anymore, they are just a piece of text for WordPress. In this case, you need to manually do it, sadly.

Solution

Simply add the following code to your theme’s functions.php file. This code simply tells the wordpress to omit any shortcodes appearing in the post exerpts on archive section.

function strip_shortcode_from_excerpt( $content ) {
    $content = strip_shortcodes( $content );
}
add_filter('the_excerpt', 'strip_shortcode_from_excerpt');

Hope so this solution helps you, if you are having any difficulty, please feel free to contact me.

Share on facebook
Share on twitter
Share on linkedin
Share on whatsapp
Share on email

One Response

Leave a Reply

Your email address will not be published.