I have used a plugin (Meta box 4.8.3) to create custom meta box and get values in custom post. If custom meta box field is text then the function returns the value. If it is image then it do not show the images.
**Register custom meta-box **
add_filter( 'rwmb_meta_boxes', 'your_prefix_meta_boxes' );
function your_prefix_meta_boxes( $meta_boxes ) {
$meta_boxes[] = array(
'title' => __( 'Image Gallery', 'textdomain' ),
'post_types' => 'events',
'fields' => array(
array(
'name' => __( 'Image Upload', 'your-prefix' ),
'id' => "{$prefix}image",
'type' => 'image'
),
),
);
return $meta_boxes;
}
To get the images the code is this
$meta = get_post_meta( get_the_ID(), '{$prefix}image', TRUE );
var_dump($meta);
echo "HAHAHAHAHA";
if($meta){
echo "HAHAHAHAHA<br>";
foreach($meta as $image) {
echo "HAHAHAHAHA";
$res.='<li>'.$image.'</li>';
}
}
?>
How can i display the images which i uploaded through the dashboard.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire