WordPress函数:remove_shortcode 删除短代码

江河/ 2023年12月03日/ WordPress/ 浏览 362

函数原型:


remove_shortcode( string $tag )


删除短代码


参数说明:


$tag,短代码名称


函数源码:


function remove_shortcode( $tag ) {
	global $shortcode_tags;

	unset( $shortcode_tags[ $tag ] );
}


使用举例:


//add a custom shortcode 
add_action( 'init', 'my_add_shortcodes' );
function my_add_shortcodes() {
	add_shortcode( 'myShortcode', 'my_shortcode_function' );
}
//which can also remove 
add_action( 'init', 'remove_my_shortcodes',20 );
function remove_my_shortcodes() {
	remove_shortcode( 'myShortcode' );
}


发表评论

暂无评论,抢个沙发...

客服 工单