WordPress古腾堡区块编辑器中的区块怎么删除或修改

WordPress古腾堡区块编辑器区块众多,让人眼花撩乱,大部分可能都用不到,我可以在编辑页面点右上角三个小点,工具 → 区块管理器中,取消某个分类的区块或者单独取消某个区块显示。

当然还可以通过下面的代码,直接删除一些不想显示的区块,依然不使用WordPress插件即可解决。

当前WordPress主题函数文件functions.php中加入以下代码:

add_filter( 'allowed_block_types', 'zm_allowed_block_types', 10, 2 );
function zm_allowed_block_types( $allowed_blocks, $post ) {
$allowed_blocks = array(
'core/image',
'core/paragraph',
'core/heading',
'core/list',
);
// 在页面编辑中单独显示的区块
if( $post->post_type === 'page' ) {
$allowed_blocks[] = 'core/shortcode';
}
return $allowed_blocks;
}

把想显示的区块名称添加进去即可,更多的区块名称:

core/shortcode
core/html
core/freeform
core/latest-posts
core/categories
core/cover (previouslycore/cover-image)
core/text-columns
core/verse
core/video
core-embed/reddit
core-embed/reverbnation
core-embed/screencast
core-embed/scribd
core-embed/slideshare
core-embed/smugmug
core-embed/speaker
core-embed/ted
core-embed/tumblr
core-embed/videopress
core/audio
core/block
core/paragraph
core-embed/twitter
core-embed/youtube
core-embed/facebook
core-embed/instagram
core-embed/wordpress
core-embed/soundcloud
core-embed/spotify
core-embed/flickr
core-embed/vimeo
core-embed/animoto
core-embed/cloudup
core-embed/collegehumor
core/image
core/gallery
core/heading
core/quote
core/embed
core/list
core/separator
core/more
core/button
core/pullquote
core/table
core/preformatted
core/code
core-embed/dailymotion
core-embed/funnyordie
core-embed/hulu
core-embed/imgur
core-embed/issuu
core-embed/kickstarter
core-embed/meetup-com
core-embed/mixcloud
core-embed/photobucket
core-embed/polldaddy
core-embed/wordpress-tv

联系我们

联系我们

13066087654

在线咨询: QQ交谈

邮箱: 2237654@qq.com

工作时间:周一至周五,9:00-17:30,节假日休息
关注微信
微信扫一扫关注我们

微信扫一扫关注我们

手机访问
手机扫一扫打开网站

手机扫一扫打开网站

返回顶部