Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Show only the methods that you need blocks in the WordPress Block Editor

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Show only the methods you need blocks in the WordPress Block Editor? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!

The following WordPress tutorial column introduces you to the method of displaying only the blocks you need in the WordPress block, hoping to help the friends who need it!

WordPress's new Gutenberg editor has been available for more than a year, and it depends on whether it is easy to use or not. Judging from the Gutenberg plug-in's score of only 2 stars, most people still can't get used to it, including me.

For users who have been messing around with WordPress for many years, it is not difficult to get started with the new editor, and the block editor still has many advantages. For example, the block editor can add a good block to the article and add and save it to the reusable block. It is very convenient to insert the article with a click the next time you use it. For example, the block editor can make use of WP's integrated front-end style and script to create a more complex responsive layout in the article.

If the article is written in a classic editor, when you go to the block editor to edit, the word "classic" will be prompted on the edit box. Click the meeting to display the toolbar of the classic editor directly in the block editor. You can also click add Block to find the "Classic" block in the "format" and insert it into the article. You can also use the previous classic editor, mixed doubles, as shown below. You can also convert previous articles to blocks, and so on.

After saying the advantages, and then talking about the disadvantages, the promotional text after the upgrade from WP:

The Block Editor, which began with WordPress 5.0, brings you new blocks, more intuitive interactions, and improved accessibility. The new features improve the design freedom of the editor, bring you more layout options and style changes, and give designers full control over the appearance of the site. This release also brings you the 2020 theme, which brings more design flexibility to users and is perfectly integrated with the block editor. Now it is easy to build beautiful web pages and advanced page layouts.

As you can see, this editor is for web designers, and most website editors simply type some text and add a picture at most, not designers, so if you have a text entry staff on your website, it's not easy for a non-professional to learn something new, and a similar editor has never been applied to other website programs. Its "advanced concept" (there was a similar visualization plug-in N years ago) will confuse users who are new to WP, which is why some people strongly oppose it, because many theme designers think that changing their original habits will be difficult for users to accept.

Since WP developers are pushing for a new editor, as a theme developer, we still need to keep pace with the times. Recently, we began to study how to convert the short code of the previous theme into blocks and integrate them into the block editor. The new blocks need a lot of JS control to achieve. The function realized by the original simple lines of code has been multiplied by the block code. For an old bird like me who has been trespassing with WP for nearly 10 years, the amount of block code has multiplied. Also need to see the official website tutorials step by step to learn, get started is not small.

Personally, I think the direction of WP program development is a little lost, and developers may not know what to upgrade besides fixing loopholes. Get a new editor to give you a "surprise". I still think it is better for this block editor to exist in the form of plug-ins, because this thing is originally a plug-in developed by others and integrated in the program.

The above is just a personal view of the new editor, and this article records that only the blocks you need are displayed in the WordPress Gutenberg editor.

Default new editor blocks are numerous, dazzling, most may not be used, you can edit the page point in the upper right corner of three small dots, tools → Block Manager, cancel a category of blocks or separately cancel a block display, you can also pass the following code, directly block out do not want to show blocks.

Add the following code to the current theme function template 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',); / / Block if ($post- > post_type =' page') displayed separately in page editing {$allowed_blocks [] = 'core/shortcode';} return $allowed_blocks;}

Just add the name of the block you want to display.

More block names:

Core/shortcode

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/html

Core/freeform

Core/latest-posts

Core/categories

Core/cover (previouslycore/cover-image)

Core/text-columns

Core/verse

Core/video

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-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/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-embed/wordpress-tv

Thank you for reading! After reading the above, do you have a general idea of how to show only the blocks you need in the WordPress Block Editor? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report