12% off of LTD using this coupon: TWELVEPERCENTOFF. Promo ends on 2 Dec midnight UTC.
Published on Feb 22, 2022

Meta Box Group’s Sub-Field Value as Oxygen Repeater Div’s Class

Sridhar Katakam

In the WPDevDesign Facebook group, a user asked:

Is there a way to get the Meta box sampling fields programmatically in the repeater? (for example, I want to use one of the group fields as a repeater div class).

This members-only tutorial provides the steps to create a custom function with group ID and sub-field ID parameters and call this function with our group ID and sub-field ID as the arguments via Hydrogen Pack's Dynamic Classes feature when using Meta Box in Oxygen.

We shall register a css_class custom field inside a Group-type of field and when this is populated for the posts a Repeater component showing the posts will automatically add the class that has been set for each post for its Div.

when editing a post
on the front end

Step 1

Install and activate Meta Box and Meta Box AIO plugins.

Go to Meta Box > Custom Fields and create a new group named say, "Post Fields".

Add a "Group" type of field and inside that, a "Text" type of field having a label of "CSS Class" so that the field ID automatically becomes "css_class".

Step 2

Edit your posts and for each, set your desired class for this post in Oxygen Repeater.

Step 3

Install and activate Code Snippets plugin.

Go to Snippets > Add New.

Title: [Function] Get MB Group Sub-Field Value


This is a premium members-only content.

To view the rest of the content, please sign up for membership ($47/month or $599 one-time).

Already a member? Log in below or here.