Q: Post customs fields dont saving values I have problem with custom fields in Wordpress. When I clicked save posts the custom fields values discarding.
My save function is:
    add_action( 'save_post', 'add_my_printer_fields', 10, 2 );

function add_my_printer_fields( $my_printer_id, $printer ) {
    // Check post type for movie reviews
    if ( $printer->post_type == 'printers' ) {
        // Store data in post meta table if present in post data
        if ( isset( $_POST['mark_of_printer'] ) && $_POST['mark_of_printer'] != '' ) {
            update_post_meta( $my_printer_id, 'mark_printer', $_POST['mark_of_printer'] );
        }
        if ( isset( $_POST['model_of_printer'] ) && $_POST['model_of_printer'] != '' ) {
            update_post_meta( $my_printer_id, 'model_printer', $_POST['model_of_printer'] );
        }
    }
}


A: Also code here:
    add_action( 'init', 'create_printers' );

function create_printers() {
    register_post_type( 'printers',
        array(
            'labels' => array(
                'name' => 'Ogłoszenia',
                'singular_name' => 'Ogłoszenie',
                'add_new' => 'Dodaj nowe',
                'add_new_item' => 'Dodaj nowe ogłoszenie',
                'edit' => 'Edytuj',
                'edit_item' => 'Edytuj ogłoszenie',
                'new_item' => 'Nowe ogłoszenie',
                'view' => 'Zobacz',
                'view_item' => 'Zobacz ogłoszenie',
                'search_items' => 'Szukaj ogłoszeń',
                'not_found' => 'Nie znaleziono ogłoszenia',
                'not_found_in_trash' => 'Nie znaleziono w koszu',
                'parent' => 'Rodzic ogłoszenia'
            ),

            'public' => true,
            'menu_position' => 20,
            'supports' => array( 'title', 'editor','post-thumbnails', 'thumbnail' ),
            'taxonomies' => array( '' ),
            'menu_icon' => plugins_url( 'images/icon-piramido.png', __FILE__ ),
            'has_archive' => true
        )
    );
}

add_action( 'admin_init', 'my_custom_fields_printers' );

function my_custom_fields_printers() {
    add_meta_box( 'printers_meta_box',
        'Twoja drukarka',
        'display_printers_meta_box',
        'printers', 'normal', 'high'
    );
}


?>

<?php
function display_printers_meta_box( $printer ) {
    // Retrieve current name of the Director and Movie Rating based on review ID
    $mark_printer = intval( get_post_meta( $printer->ID, 'mark_printer', true ) );
    $model_printer = intval( get_post_meta( $printer->ID, 'model_printer', true ) );
    ?>
    <table>
          <tr>
            <td style="width: 150px">Marka drukarki</td>
            <td>
                <select style="width: 300px" name="mark_of_printer">
                <option value="<?php echo $mark_printer+1;?>">SAMSUNG</option>
                                    <option value="<?php echo $mark_printer+2;?>">HP</option>
                                    <option value="<?php echo $mark_printer+3;?>">XEROX</option>
                                    <option value="<?php echo $mark_printer+4;?>">BROTHER</option>
                                    <option value="<?php echo $mark_printer+5;?>">MINOLTA</option>
                </select>
            </td>
        </tr>
        <tr>
            <td style="width: 150px">Model drukarki</td>
            <td>
                <select style="width: 300px" name="model_of_printer">
                    <option value="<?php echo $model_printer+1;?>">ProXpress SL-M3320ND</option>
                                    <option value="<?php echo $model_printer+2;?>">SL-M2885FW</option>
                                    <option value="<?php echo $model_printer+3;?>">Xpress M2675FN</option>
                                    <option value="<?php echo $model_printer+4;?>">SL-M2070FW</option>
                                    <option value="<?php echo $model_printer+5;?>">LaserJet Pro M102w</option>
                                    <option value="<?php echo $model_printer+6;?>">Neverstop 1000w</option>
                                    <option value="<?php echo $model_printer+7;?>">Color Laser 150nw</option>
                                    <option value="<?php echo $model_printer+8;?>">B215V_DNI</option>
                                    <option value="<?php echo $model_printer+9;?>">WorkCentre 6515V</option>
                                    <option value="<?php echo $model_printer+10;?>">VersaLink C9000V</option>
                                    <option value="<?php echo $model_printer+11;?>">HL-1222WE</option>
                                    <option value="<?php echo $model_printer+12;?>">MFC-J5730DW</option>
                                    <option value="<?php echo $model_printer+13;?>">MFC-9332CDW</option>
                                    <option value="<?php echo $model_printer+14;?>">Bizhub 282</option>
                                    <option value="<?php echo $model_printer+15;?>">Bizhub C258</option>
                </select>
            </td>
        </tr>
    </table>
    <?php
}

