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

WordPress评论248阅读模式

如果准备在某篇文章中不显示短代码,可以将下面代码添加到当前主题函数模板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://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

本站文章大部分始于原创,用于个人学习记录,可能对您有所帮助,仅供参考!

weinxin
我的微信
版权声明
本站原创文章转载请注明文章出处及链接,谢谢合作!
 
知更鸟
匿名

发表评论

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

拖动滑块以完成验证