Strip Shortcode Tags and NOT the content

I use a lot of shortcodes on my sites when the user has a lot of requirements for me in design. One issue you have is when the content is displayed in a slider or any other specific area while strip_tags is being used, it looks pretty weird. Something like the following

[shortcode] some paragraph text here [/shortcode]

So the solution is preg_match.

echo substr(preg_replace( '/\[[^\]]+\]/', '', get_the_content() )


Warning: count(): Parameter must be an array or an object that implements Countable in /home/alihs/domains/ on line 399

Leave a Reply

Your email address will not be published. Required fields are marked *