【问题标题】:Get Gallery Caption, Image Caption & Gallery Settings When Filtering WP Core Gallery Block过滤 WP Core 图库块时获取图库标题、图像标题和图库设置
【发布时间】:2020-04-20 13:53:02
【问题描述】:

当我像这样过滤 WP Core Gallery 块时:

add_filter( 'render_block', function( $block_content, $block )
{
    if ( 'core/gallery' === $block['blockName'] )
    {
        var_dump( $block );
    }
}, 10, 2 );

我得到类似的东西:

array(5) {
  ["blockName"]=>
  string(12) "core/gallery"
  ["attrs"]=>
  array(1) {
    ["ids"]=>
    array(2) {
      [0]=>
      int(200)
    }
    ["className"]=>
    string(12) "custom-class"
  }
  ["innerBlocks"]=>
  array(0) {
  }
  ["innerHTML"]=>
  string(2630) "[...]"
  ["innerContent"]=>
  array(1) {
    [0]=>
    string(2630) "[...]"
  }
}

我想念的是图片标题和图库标题:

所有其他设置(className 除外)也不可用:

那么如何访问所有设置???

澄清:我不是wp_get_attachment_metadata

提前致谢,祝大家新年快乐!

【问题讨论】:

    标签: php wordpress wordpress-gutenberg wordpress-hook


    【解决方案1】:

    标题在 $block['innerHTML'] 内。

    【讨论】:

      猜你喜欢
      • 2014-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多