如何从 Twig/Timber 中的组的选项页面显示高级自定义字段 - WordPress

问题描述

因此,如果我的“选项”页面上有一组名为 product_tools 的字段,以及 tool_link、tool_picture 和 tool_name 我正试图在带有树枝的页面显示它,但它对我不起作用? {{ options.product_tools.tool.name }} 当我进行转储时,我可以很好地获取数组中的所有字段。

这里是转储:{{ dump(options.product_tools) }}

C:\Users\WpDev\Local Sites\protoolsite\app\public\wp-content\plugins\timber-library\vendor\twig\twig\src\Extension\DebugExtension.PHP:70:
array (size=3)
  'tool_link' => string 'https://www.dewalt.com/products/power-tools' (length=43)
  'tool_picture' => 
    array (size=24)
      'ID' => int 307
      'id' => int 307
      'title' => string 'band-saw' (length=8)
      'filename' => string 'band-saw.jpg' (length=12)
      'filesize' => int 103647
      'url' => string 'http://protoolsite.local/wp-content/uploads/2021/07/band-saw.jpg' (length=69)
      'link' => string 'http://protoolsite.local/band-saw/' (length=39)
      'alt' => string '' (length=0)
      'author' => string '1' (length=1)
      'description' => string '' (length=0)
      'caption' => string '' (length=0)
      'name' => string 'band-saw' (length=8)
      'status' => string 'inherit' (length=7)
      'uploaded_to' => int 0
      'date' => string '2021-07-13 14:37:29' (length=19)
      'modified' => string '2021-07-13 14:37:29' (length=19)
      'menu_order' => int 0
      'mime_type' => string 'image/jpeg' (length=10)
      'type' => string 'image' (length=5)
      'subtype' => string 'jpeg' (length=4)
      'icon' => string 'http://protoolsite.local/wp-includes/images/media/default.png' (length=66)
      'width' => int 1000
      'height' => int 1000
      'sizes' => 
        array (size=18)
          'thumbnail' => string 'http://protoolsite.local/wp-content/uploads/2021/07/band-saw-150x150.jpg' (length=77)
          'thumbnail-width' => int 150
          'thumbnail-height' => int 150
          'medium' => string 'http://protoolsite.local/wp-content/uploads/2021/07/band-saw-300x300.jpg' (length=77)
          'medium-width' => int 300
          'medium-height' => int 300
          'medium_large' => string 'http://protoolsite.local/wp-content/uploads/2021/07/band-saw-768x768.jpg' (length=77)
          'medium_large-width' => int 768
          'medium_large-height' => int 768
          'large' => string 'http://protoolsite.local/wp-content/uploads/2021/07/band-saw.jpg' (length=69)
          'large-width' => int 1000
          'large-height' => int 1000
          '1536x1536' => string 'http://protoolsite.local/wp-content/uploads/2021/07/band-saw.jpg' (length=69)
          '1536x1536-width' => int 1000
          '1536x1536-height' => int 1000
          '2048x2048' => string 'http://protoolsite.local/wp-content/uploads/2021/07/band-saw.jpg' (length=69)
          '2048x2048-width' => int 1000
          '2048x2048-height' => int 1000
  'tool_name' => string 'Dewalt Bandsaw' (length=14)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)