I’ve been trying to figure out how to use the Field ‘Group’ using Metabox AIO and displaying the content on the front end with a code block.
I can’t seem to find any documentation lately for use of the Metabox AIO as most of what I find seems to be for using functions to build the custom fields.
I’ve taken one of your examples and I’ve built a group with an ID of ‘cars’ that is cloneable. I’ve added 3 fields with IDs of ‘brand’, ‘date’ and ‘color’.
I’ve attached it to a page and added 3 different cars.
In a code block I’ve placed this code:
<?php
$cars = rwmb_meta( 'car' ); // ID of the group
foreach ( $cars as $car ) {
if ( ! empty( $car ) ) {
echo '<h4>Car info</h4>';
echo '<p>Brand: ', $car['brand'], '</p>'; // Access sub-field via its ID.
echo '<p>Date: ', $car['date'], '</p>';
echo '<p>Color: <span style="color:', $car['color'], '"><strong>Colour</strong></span></p>';
}
}
?>
It’s display the 3 different cars that I inputed values for perfectly.
Where I’m having a problem is when I add a 4th custom field of Single Image with ID of ‘my_image’ and add an image to each of the cars. I’ve tried pretty much everything I could think of code wise to display the image on the frontend but haven’t been successful.
Was hoping you might be able to straighten me out. Any help with this would be greatly appreciated.