Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 创建特定于页面和帖子的ACF Gutenberg块_Php_Wordpress_Custom Post Type_Wordpress Gutenberg_Acf Gutenberg - Fatal编程技术网

Php 创建特定于页面和帖子的ACF Gutenberg块

Php 创建特定于页面和帖子的ACF Gutenberg块,php,wordpress,custom-post-type,wordpress-gutenberg,acf-gutenberg,Php,Wordpress,Custom Post Type,Wordpress Gutenberg,Acf Gutenberg,我正在创建自定义ACF Gutenberg blocks我的a站点,并已成功注册我自己的blocks。现在,我有了一个名为Blog的自定义帖子类型。我不想blog显示我所有的ACF Gutenberg块,我只想创建一个单独的批,用于自定义文章类型。我已经启用了show\u in\u rest,但即使是默认的Gutenberg博客也不会为我显示 我的做法如下: 1。注册帖子类型(theme/functions.php) 也许这样可以解决问题: 为博客英雄指定post_类型paramBlog $b

我正在创建自定义ACF Gutenberg blocks我的a站点,并已成功注册我自己的blocks。现在,我有了一个名为
Blog
的自定义帖子类型。我不想
blog
显示我所有的ACF Gutenberg块,我只想创建一个单独的批,用于自定义文章类型。我已经启用了
show\u in\u rest
,但即使是默认的Gutenberg博客也不会为我显示

我的做法如下:

1。注册帖子类型(theme/functions.php)

也许这样可以解决问题: 为博客英雄指定
post_类型
paramBlog

$blog_hero = array(
    'name'            => 'blog_hero',
    'title'           => __( 'Blog hero', 'Context' ),
    'description'     => __( '', 'Context' ),
    'render_callback' => 'block_render',
    'category'        => 'formatting',
    'icon'            => 'admin-comments',
    'keywords'        => array(
        'hero',
        'blog'
    ),
    'post_types'      => array( 'blog' ),
);
类似地,为Hero block指定除博客之外的所有帖子类型

$all_post_types        = get_post_types();
$hero_block_post_types = array_diff( $all_post_types, array( 'blog' ) );

$hero = array(
    'name'            => 'hero',
    'title'           => __( 'Hero', 'Domain' ),
    'description'     => __( '', 'Domain' ),
    'render_callback' => 'block_render',
    'category'        => 'formatting',
    'icon'            => 'admin-comments',
    'keywords'        => array(
        'hero'
    ),
    'post_types'      => $hero_block_post_types
);

$blocks = [ $hero ];

return $blocks;
注意:

考虑为您的
\uu
函数添加域。 在域中使用
\函数的良好实践。

这有帮助吗:?