PIT Designs Logo

ACF Repeater Table in Oxygen Builder

I'm the owner and founder of PIT Designs. I love creating digital presence and creative digital solutions for our clients.


Posted 2 years ago on August 14th, 2019. Last modified on June 7th, 2020


Tags: | | |

Recommended
The best free alternative to Grammarly : ProWriteAid
Up to 35% OFF AliDropship Plugin

How to create and style an HTML Table in Oxygen builder using dynamic data from ACF Repeater table.

With the recent updates of Oxygen bringing the Repeater fields to the builder. It's a great addition, which opens up to a lot of possibilities. One particular use that I needed for the Oxygen Repeater module (using ACF Repeater) is to output the results as a table.

The builtin Repeater in Oxygen builder doesn't allow for such manipulation at the moment. However, there's a workaround solution to get Oxygen builder output ACF Repeater table. Which you can style further with the magic of CSS.

Step 1: Starting ACF Repeater table

Create your custom repeater fields, in this example I'll create a simple [subject] [result] table. The method can be replicated to any number of columns.

Create a field group:

Label: Subject & Results

Field name: r_subject_&_results

Field type: Repeater

ACF Repeater table

Expand the Repeater field and add the nested fields. In this case will be:

Label: Subject with field name: r_subject.

Label: Result with field name: r_result

ACF Repeater to Table

Step 2: Using Oxygen Builder

Create the template, page, any other CPT you want to add the table to.

Insert the Code Module, and add below PHP code:

<!--
r_subject_&_results = ACF Repeater
r_subject = Field 1
r_result = Field 2
--><!-- repeater fields table output-->
<?php
$i = 0;
if( have_rows('r_subject_&_results') ): ?><table class="r-table"><tr><th>Subject</th><th>Result</th></tr><?php while( have_rows('r_subject_&_results') ): the_row(); $i++;$post = get_sub_field('r_subject');if( empty($post) )
{
continue;
}setup_postdata( $post );?><?php if( $i == 1 ): ?>

<tr>
<?php endif; ?>

<td><?php the_sub_field('r_subject'); ?></td>
<td><?php the_sub_field('r_result'); ?></td>

</tr>

<?php if( $i == 2 ): $i = 0; ?>

<?php endif; ?>

<?php endwhile; ?>

<?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>

<?php endif; ?>
</table>

The above code will basically create a table based on the ACF repeater fields r_subject and r_result

Step 3. Applying CSS Styles to the Table

As you can see in the above code, the table is created and given a class of r-table


<table ID="r-table">

And just like an HTML Table it has < th > and < tr > that you can style further.

This is easily done with CSS. Here's a reference to CSS Tables styling on W3School.

if you have any question, feel free to write in the comments below.

Happy Oxygen-ing!

5/5 (3 Reviews)
Do we all agree that Coffee is the fuel that feeds the free content creating?
Connecting Databases to Google Sheets with KPIBees

One of those tools that help connect and process data from Google Sheets to Databases, is KPIBees. Find out more in this post

UseSQL to connected data across Google Sheets, Airtables & More

UseSQL allows you to easily turn your data into databases by connecting data across multiple apps.The data source can be […]

10 Tips For Improving Productivity Of Remote Teams

Freelancers are used to working from home. They can work from anywhere in the world with a decent Internet connection […]

Boost Your Business Strategy With Vizologi

Vizologi is a unique platform helps you shape your business strategy. bringing creative ideas to life. boost tour business strategy.

Online PDF To Flipbook Converter

Heyzine is the best way to create awesome online publications convert PDF to Flipbooks

Landing Pages Optimization: Writing & Design Tips

Landing page optimization writing and design tips to help you build the best landing page for your business, product, and services.

App Development Agency: Here’s Why You Need A Mobile App

Getting credible services from a legit app development agency is essential. Here’s an article to read why an app can help your business.

Leave a Reply

Your email address will not be published. Required fields are marked *

menu-circlecross-circle