【问题标题】:How to use a Wordpress Gutenberg block programmatically into the theme?如何以编程方式在主题中使用 Wordpress Gutenberg 块?
【发布时间】:2020-07-15 01:52:59
【问题描述】:

我正在开发一个 100% 基于 Gutenberg 块的 wordpress 主题。有些页面是直接在编辑器上构建的(例如主页),但其他页面(例如搜索结果)需要编码。

例如,我想使用帖子网格块显示我的搜索结果。

是否可以以编程方式调用 Gutenberg 块,即在我的主题代码上,发送参数并取回 html 代码?例如,就像我们对do_shortcode() 所做的那样?

【问题讨论】:

    标签: php wordpress wordpress-gutenberg gutenberg-blocks


    【解决方案1】:

    这取决于您感兴趣的块的类型,其中大部分是完全用 JavaScript 编写和呈现的 - 看看 Block Editor HandbookDynamic Blocks

    【讨论】:

    • 感谢 DOBss。我明白你的意思,但提供整个文档的链接对我和其他寻找相同问题的人没有帮助。如果想进一步回答,请考虑例如原子块。
    猜你喜欢
    • 2019-05-09
    • 1970-01-01
    • 1970-01-01
    • 2019-04-15
    • 2020-12-03
    • 2018-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多