在WordPress 指定文章中不显示短代码

知更鸟 WordPress评论133阅读模式

如果准备在某篇文章中不显示短代码,可以将下面代码添加到当前主题函数模板functions.php中:

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

修改其它中的数字123为文章ID文章源自知更鸟-https://zmingcx.com/shortcodes-are-not-displayed-in-wordpress-posts.html

文章源自知更鸟-https://zmingcx.com/shortcodes-are-not-displayed-in-wordpress-posts.html

参考自:文章源自知更鸟-https://zmingcx.com/shortcodes-are-not-displayed-in-wordpress-posts.html

https://www.isitwp.com/remove-shortcode-from-home-but-not-single-posts/
https://stackoverflow.com/questions/40960756/how-to-disable-shortcodes-in-pages-posts-with-a-certain-string-in-the-url文章源自知更鸟-https://zmingcx.com/shortcodes-are-not-displayed-in-wordpress-posts.html

文章源自知更鸟-https://zmingcx.com/shortcodes-are-not-displayed-in-wordpress-posts.html文章源自知更鸟-https://zmingcx.com/shortcodes-are-not-displayed-in-wordpress-posts.html
weinxin
版权声明
本站原创文章转载请注明文章出处及链接,谢谢合作!
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定