0
votes

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.

1
Can you post some code on what you tried already?msg
I used the code posted in the link, and i tried with: 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; But i got NULL from the dumpJoakim
Are you calling get_sub_field() at any point?msg
I have tried to do that too, but it does not seem to get any result.Joakim

1 Answers

0
votes

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;