Skip to content

Instantly share code, notes, and snippets.

@utkrishta
Created February 14, 2022 23:35
Show Gist options
  • Save utkrishta/0ce35f647f4bdeedd52df2ecb3b54acc to your computer and use it in GitHub Desktop.
Save utkrishta/0ce35f647f4bdeedd52df2ecb3b54acc to your computer and use it in GitHub Desktop.
Displaying field values from metabox cloneable(repeater) fields
<?php
//get repeater field called 'services'
$services = rwmb_meta( 'services' );
if ( ! empty( $services ) ) {
foreach ( $services as $service ) {
//retrieve each values from subfield inside the services field
echo wp_get_attachment_image( $service['services_image'], 'full' );
echo $service['services_title'];
echo $service['services_description'];
//there is a repeater subfield within this called 'services_links'
//we need to check if it has any value first, hence check for array key's existance
if ( array_key_exists( 'services_links', $service ) ) {
$links = $service['services_links'];
if ( ! empty( $links ) ) {
foreach ( $links as $link ) {
echo get_permalink( $link );
}
}
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment