admin管理员组文章数量:1335624
I've registered a block pattern in my custom theme (using register_block_pattern) and it's not displaying in the block patterns list so I'm trying to debug whether I registered it properly.
How could I programmatically find currently registered block patterns?
I've registered a block pattern in my custom theme (using register_block_pattern) and it's not displaying in the block patterns list so I'm trying to debug whether I registered it properly.
How could I programmatically find currently registered block patterns?
Share Improve this question asked Jun 30, 2020 at 19:07 WillWill 7617 silver badges24 bronze badges1 Answer
Reset to default 3This looks like quite new functionality, the docs say 'experimental' and the first commit of this code to the WP repo was 6 days ago from date of this writing, so wouldn't be surprised if you'll have issues with what you're doing related to it being in development.
The class that manages block patterns is easy to read:
https://github/WordPress/WordPress/blob/6d927e494c160a04b641518009995f54212cd9f6/wp-includes/class-wp-block-patterns-registry.php
So you could call e.g. the get_all_registered()
method like:
WP_Block_Patterns_Registry::get_instance()->get_all_registered()
or e.g. check if your pattern is registered:
WP_Block_Patterns_Registry::get_instance()->is_registered("your_pattern_name")
I'd suggest if you're having problems you might either want to wait until it's a more stable feature or contact the people working on it (e.g. you could start by contacting the person who made that commit as it looks like they're actively working on it)
HTH!
本文标签: How to view all currently registered block patterns
版权声明:本文标题:How to view all currently registered block patterns? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742304553a2449654.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论