0

Hi i have a metabox that works when i want to save value as text but when i use input file and make it multiple it doesnt save the values for me to use it in single post . whaats the problem ? this is my code

function diwp_custom_metabox(){
 
    add_meta_box( 
                    'diwp-metabox',
                    'My Custom Metabox',
                    'diwp_custom_metabox_callback',
                    'post',
                    'normal'
                );
}
 
add_action('add_meta_boxes', 'diwp_custom_metabox');
 
 
function diwp_custom_metabox_callback(){
     
    global $post;
     
    ?>
 
    <div class="row">
        <div class="label">Post Reading Time</div>
        <div class="fields">
            <input multiple type="file" name="_diwp_reading_time" value="<?php echo get_post_meta($post->ID, 'post_reading_time', true)?>"/>
        </div>
    </div>
 
    <?php
 
}
 
function diwp_save_custom_metabox(){
 
    global $post;
 
    if(isset($_POST["_diwp_reading_time"])):
         
        update_post_meta($post->ID, 'post_reading_time', $_POST["_diwp_reading_time"]);
     
    endif;
}
 
add_action('save_post', 'diwp_save_custom_metabox');

here it echo nothing in single post even i put it in a foreach loop

<?php
                        $meta_print_value=get_post_meta(get_the_ID(),'post_reading_time',true);
                        echo $meta_print_value;
                        echo '<div class="image-item  animate-box">
                        <img src="' . $meta_print_value . '" class="img-responsive" alt="Free HTML5 Bootstrap Template by FreeHTML5.co">
                         </div>';
                    ?>

0 Answers0