Created
February 14, 2022 23:35
-
-
Save utkrishta/0ce35f647f4bdeedd52df2ecb3b54acc to your computer and use it in GitHub Desktop.
Displaying field values from metabox cloneable(repeater) fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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