內容簡介
**WordPress 外掛總結:**
這個外掛讓你可以在網站編輯模板中新增一個額外的區塊內容區域,並將區塊輸出儲存在 meta 欄位中。預設情況下,外掛會為所有文章類型添加一個名為 extra_content_area 的新 meta 欄位,你可以使用來儲存區塊標記。若要停用這個 meta 金鑰的註冊,可在您的主題或外掛中添加以下內容:
```php
add_filter( 'content_area_block_register_default_meta', '__return_false' );
```
問題與答案:
1. 如何停用此外掛所新增的 meta 金鑰的註冊?
答: 您可以在您的主題或外掛中添加以下內容:
```php
add_filter( 'content_area_block_register_default_meta', '__return_false' );
```
2. 使用這個外掛需注意的事項是什麼?
答: 您需要啟用模板預覽功能,這樣可以讓您視覺化看到您新增的新內容區域。這可以在任何帖子或頁面上啟用,但您也可以使用過濾器將其默認打開。
3. 如果我想參與貢獻,可以在哪裡找到外掛的源代碼?
答: 您可以在以下網址找到外掛的源代碼: [https://github.com/iansvo/content-area-block](https://github.com/iansvo/content-area-block)。 若要從源代碼構建外掛,您必須安裝 NodeJS (v24+)。
4. 請說明外掛的設置步驟。
答:
- 在終端機中瀏覽到專案文件夾。
- 運行 npm i 以安裝依賴項。
- 運行 npm run build 執行初始構建。
5. 如果我正在使用 wp-env 來運行外掛,應該遵循哪些步驟?
答:
1. 運行 npm run wp-env start 以啟動 Docker 容器。
2. 運行 npm run start 以監視文件變更。
外掛標籤
開發者團隊
原文外掛簡介
This block allows you to add an additional block content area to a site-editor template and store the block output inside a meta field. By default, WordPress posts or pages may only store blocks in one place: post_content. These blocks are output on the page using the core/post-content block. This block allows you to have multiple “outlets” where you can add blocks so you can have post-specific blocks appear in more than one location in the template.
The block is a fork of the core/post-content block that uses a customized version of the useEntityBlockEditor hook which supports meta keys. The blocks for your content area are then stored inside that meta key (instead of post_content). This allows you to keep the blocks separate and you can use as many of these on a single template as you want (but in most cases 2 is probably enough). It’s all up to you!
Requirements
Using this plugin requires you to enable template previews (which will let you visually see the new content area you’re adding). This can be enabled on any given post or page, but you can optionally set it on by default using a filter.
Your theme must be a block theme (i.e. it uses the site editor). This won’t work for a hybrid or classic theme (which has no concept of live template preview in the block editor).
Hooks
If you want to disable this meta key’s registration, add the following to your theme or plugin:
$block_post_id,
$attributes,
$content,
$block
);
Contributing
The plugin source code may be found here: https://github.com/iansvo/content-area-block.
To build the plugin from source, you must have NodeJS (v24+) installed.
Setup Steps:
Navigate to the project folder in your terminal.
Run npm i to install dependencies.
Run npm run build to performn the initial build.
If you’re using wp-env to run the plugin…
1. Run npm run wp-env start to start the docker container.
2. Run npm run start to watch for file changes.
