WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/strip shortcodes

Description

Deletes all shortcode tags from the given content.

Usage

<?php strip_shortcodes$content ); ?>

Parameters

$content
(string) (required) Content to remove shortcode tags from.
Default: None

Return Values

(string) 
Content without shortcode tags.

Examples

Strip shortcodes on home page but not on single or archive pages

When viewing posts 'home' page, strip all shortcodes, but on other pages, such as single.php, do not strip the shortcodes.

function remove_shortcode_from_index( $content ) {
  if ( is_home() ) {
    $content = strip_shortcodes( $content );
  }
  return $content;
}
add_filter( 'the_content', 'remove_shortcode_from_index' );

Notes

Change Log

Since: 2.5

Source File

strip_shortcodes() is located in wp-includes/shortcodes.php.

Related

Shortcode API

See also index of Function Reference and index of Template Tags.