Build table using Advanced Custom Fields
I have a table that populates data pulled from ACF. It basically adds a PDF of a report if there's one available. I think I got that part figured out, but my code is awfully complicated and I'll like to simplify it with a switch statement or something similar. Also, how do I get the table to display a value of 'x' when there's no PDF file available? It's currently removing the cell and I don't want it to do that. Thanks in advance.
table class="float-left table"
thead
tr
th scope="col"Company/th
th scope="col"Annual Report/th
th scope="col"Interim Statement/th
th scope="col"Prospectus/th
/tr
/thead
tbody
?php if( $query-have_posts() ) : while( $query-have_posts() ) : $query-the_post(); ?
?php if( have_rows( 'recent_documents') ): ?
tr
th
a href="?php the_permalink(); ?"
?php the_title(); ?
/a
/th
?php while( have_rows( 'recent_documents') ): the_row(); ?
?php if ( have_rows( 'new_document') ): ?
?php while ( have_rows( 'new_document') ): the_row(); ?
?php if (strpos(get_sub_field( 'report_type'), "Annual") !==false): ?
tda href="?php the_sub_field('file'); ?" target="_blank"i class="fas fa-file-pdf"/iannual/a
/td
?php endif; ?
?php if (strpos(get_sub_field( 'report_type'), "Interim") !==false): ?
tda href="?php the_sub_field('file'); ?" target="_blank"i class="fas fa-file-pdf"/iinterim/a
/td
?php endif; ?
?php if (strpos(get_sub_field( 'report_type'), "Prospectus") !==false): ?
tda href="?php the_sub_field('file'); ?" target="_blank"i class="fas fa-file-pdf"/iProspectus/a
/td
?php endif; ?
?php endwhile; ?
?php endif; ?
?php endwhile; ?
/tr
?php endif; ?
?php endwhile; endif; wp_reset_postdata(); ?
/tbody
/table
Topic advanced-custom-fields join-tables Wordpress
Category Web