WordPress 常用函数 / strip_shortcodes
删除置顶内容中的所有短代码标签。
<?php strip_shortcodes( $content ); ?>
<?php strip_shortcodes( $content ); ?>$content
(string) (required) 将要删除所有短代码标签的字符串。
Default: None
(string)
删除了所有段代码标签的字符串。
除了 single 和 page 页面之外删除 Shortcode。
function wpjam_remove_shortcode_from_archive($content) {
if ( !is_singular() ) {
$content = strip_shortcodes( $content );
}
return $content;
}
add_filter('the_content', 'wpjam_remove_shortcode_from_archive');
Since: 2.5
wp-includes/shortcodes.php