• I’m using the simple video embedder plugin on my site. To embed a video with it, you enter the short code [simple_video]

    The problem is, if it is near the beginning of my post, then on the main page it shows up in the excerpt field as just the raw text [simple_video]. I would like to make it either show the actual video, or just strip that text out altogether.

    I’ve googled this like crazy and there is lots of info but not really any solutions (at least not that worked for me). I played with filters a bit but they’re a little over my head.

Viewing 3 replies - 1 through 3 (of 3 total)
  • To remove a shortcode like:
    [media-credit param=value param2="value2"]text you actually want goes here[/media-credit]
    You can use the following to your functions.php file:

    add_filter( 'the_excerpt', 'remove_media_credit_from_excerpt' );
    function remove_media_credit_from_excerpt( $excerpt ) {
    	return preg_replace ('/\[media-credit[^\]]*\](.*)\[\/media-credit\]/', '$1', $excerpt);
    }

    I’m not sure how the [simple_video] shortcode works, but you should be able to adjust the above to make it work.

    Thank you sbressler, this worked great for my WordPress site.

    legend i had a similar problem great way to do it ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Remove short code from excerpt’ is closed to new replies.