Reputation: 161
I want to display multiple image coming from meta box image.It display 'Array' as a result. I want to show images insted of 'Array.'
Meta box image code in function.php file:
add_filter( 'rwmb_meta_boxes', 'YOURPREFIX_register_meta_boxes' );
function YOURPREFIX_register_meta_boxes( $meta_boxes ) {
$prefix = 'rw_';
$meta_boxes[] = array(
'id' => 'personal3',
'title' => __( 'Image', 'textdomain' ),
'post_types' => array( 'post', 'page' ),
'fields' => array(
array(
'name' => __( 'Photo', 'textdomain' ),
'id' => $prefix . 'Photo',
'type' => 'image',
'force_delete' => false,
// Maximum image uploads
'max_file_uploads' => 4,
// Display the "Uploaded 1/2 files" status
'max_status' => true,
),
)
);
return $meta_boxes; }
Display code in loop.php file:
<?php
echo $myvar = rwmb_meta( 'rw_Photo');
?>
Upvotes: 2
Views: 1205
Reputation: 2887
array of images
add below foreach loop in your loop
<?php
$myvar_array = rwmb_meta( 'rw_Photo');
foreach ( $myvar_array as $myvar_value )
{
//$myvar_value['url']
?>
<img src="<?php echo $myvar_value['url']; ?>" />
<?php
}
?>
Upvotes: 3