This is the code… I just started learning wordpress and any help would be welcomed… This is not a plugin,it was coded in functions.php…. I just need to know what to do to display this on front-end… Thanks

function adding_custom_meta_boxes( ) {
add_meta_box( 
    'custom_meta',
    'Katalog',
    'custom_meta_callback',
    'custom'
);
}
add_action( 'add_meta_boxes', 'adding_custom_meta_boxes', 10, 2 );

function custom_meta_callback( $post ) {

wp_nonce_field( basename( __FILE__ ), 'custom_nonce' );
$custom_stored_meta = get_post_meta( $post->ID);

?>
<div class="container">
    <label for="ime-proizvoda">Model: <input type="text" 
name="ime_proizvoda" id="ime-proizvoda" value="<?php if ( ! empty ( 
$custom_stored_meta['ime_proizvoda'] )) echo esc_attr( 
$custom_stored_meta['ime_proizvoda'][0] ); ?>"></label><br>
    <label for="snaga-proizvoda">Snaga: <input type="text" 
name="snaga_proizvoda" id="snaga-proizvoda" value="<?php if ( ! empty ( 
$custom_stored_meta['snaga_proizvoda'] )) echo esc_attr( 
$custom_stored_meta['snaga_proizvoda'][0] ); ?>">kw</label><br>
    <label for="ste">Stepen Iskorišćenja Energije: <input type="text" 
name="ste" id="ste" value="<?php if ( ! empty ( $custom_stored_meta['ste'] 
)) echo esc_attr( $custom_stored_meta['ste'][0] ); ?>">%</label><br>
    <label for="pdi">Prečnik Dimovodnog Izlaza: <input type="text" 
name="pdi" id="pdi" value="<?php if ( ! empty ( $custom_stored_meta['pdi'] 
)) echo esc_attr( $custom_stored_meta['pdi'][0] ); ?>">mm</label><br>
    <label for="obrada">Završna Obrada: <input type="text" name="obrada" 
id="obrada" value="<?php if ( ! empty ( $custom_stored_meta['obrada'] )) 
echo 
esc_attr( $custom_stored_meta['obrada'][0] ); ?>"></label><br>
    <span>Opis Proizvoda:</span>
    <div class="editor">
        <?php 
            $content = get_post_meta( $post->ID, 'opis_proizvoda', true);
            $editor = 'opis_proizvoda';
            $settings = array(
                'textarea_rows' => 5,
                'media_buttons' => true,
                );

            wp_editor($content, $editor, $settings);
        ?>
    </div>
</div>

<?php

}

function custom_meta_save( $post_id ) {
 $is_autosave = wp_is_post_autosave($post_id);
 $is_revision = wp_is_post_revision($post_id);
 $is_valid_nonce = (isset($_POST['custom_nonce']) && 
wp_verify_nonce($_POST['custom_nonce'],basename( __FILE__ ))) ? 'true' : 
'false';

if ($is_autosave || $is_revision || !$is_valid_nonce) {
    return;
    }
if (isset($_POST['ime_proizvoda'])) {
    update_post_meta($post_id, 'ime_proizvoda', 
sanitize_text_field($_POST['ime_proizvoda']) );
    }
if (isset($_POST['snaga_proizvoda'])) {
    update_post_meta($post_id, 'snaga_proizvoda', 
sanitize_text_field($_POST['snaga_proizvoda']) );
    }
if (isset($_POST['ste'])) {
    update_post_meta($post_id, 'ste', sanitize_text_field($_POST['ste']) );
    }
if (isset($_POST['pdi'])) {
    update_post_meta($post_id, 'pdi', sanitize_text_field($_POST['pdi']) );
    }
if (isset($_POST['obrada'])) {
    update_post_meta($post_id, 'obrada', 
sanitize_text_field($_POST['obrada']) );
    }
if (isset($_POST['opis_proizvoda'])) {
    update_post_meta($post_id, 'opis_proizvoda', 
sanitize_text_field($_POST['opis_proizvoda']) );
    }
}
add_action('save_post', 'custom_meta_save');

Read more here: how to print custom meta boxes on the front end?


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: