• 0点赞

  • 0收藏

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

 

版权声明:追格所提供的文章、图片等内容均为用户发布或互联网整理而来,仅供学习参考,如有侵犯您的版权,请联系我们www#zhuige.cn(#为@)删除。

发表评论

电子邮件地址不会被公开。 必填项已用*标注

评论信息

TOP