簡體   English   中英

中繼器字段中的ACF中的輸出表

[英]output table in ACF that is in a repeater field

我正在顯示一些表,並且我的表字段位於重復器字段中,因為我要彼此顯示4個表,它們是彼此的一部分。

我正在查看代碼,看到它返回的數組為4。

我看過以下代碼: https : //wordpress.org/plugins/advanced-custom-fields-table-field/#screenshots但這僅在表位於普通字段而不是位於重復字段內時才起作用。 我無法獲得任何信息。

我一直在嘗試通過repeater字段循環,然后為該表運行代碼,但這似乎不起作用,我從轉儲中得到的都是NULL

if( have_rows($table) ): // loop through the rows of data 
  while ( have_rows($table) ) : the_row();
    var_dump($table['information_table']) 
  endwhile; 
else : 
  // no rows found 
endif;

任何人對我如何從中繼器字段中顯示表格都有任何提示?

謝謝。

中繼台
插件作者提供了以下代碼示例:不知道您缺少什么。 嘗試不使用$ table變量,而僅使用字段名稱。 驗證您使用的是正確的sub_field名稱。 仔細檢查您是否已將數據保存在數據庫中。 看來您應該使用sub_field('information_table')而不是$ table ['information_table']

// check if the repeater field has rows of data
if( have_rows('repeater_field_name') ):

  // loop through the rows of data
  while ( have_rows('repeater_field_name') ) : the_row();

    // get a sub field value (table field)
    $table = sub_field('sub_field_name');

    // use the “Output Table HTML” code with $table   

  endwhile;

else :

  // no rows found

endif;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM