简体   繁体   中英

output table in ACF that is in a repeater field

I'm doing some displaying of tables and my table field is in a repeater field since i want to display 4 tables after each other that is a part of each other.

I'm looking at the code and see that it returns an array of 4.

I have looked at this code: https://wordpress.org/plugins/advanced-custom-fields-table-field/#screenshots But that only seem to work if the table is in a normal field and not inside a repeater field. I can't get any information out of it.

I have been trying to loop trough the repeater field and then run the code for the table, but that does not seem to work, all I get from the dump is 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;

Anyone that has any tips on how i can get the tables to show from a repeater field?

Thanks.

repeater tables
The plugin author provides this code example: Not sure what you are missing. Try without the $table variable and use just the field name. Verify that you are using the correct sub_field name. Double check that you have the data saved in your database. It looks like you should be using sub_field('information_table') instead of $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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM