• Resolved dileepraja

    (@dileepraja)


    Hi i got the problem i create custom meta box the i am updating the value it’s disappearing but i am getting the content in front pages

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter dileepraja

    (@dileepraja)

    function metabox1_rendering($page)
    {
    	$values= get_post_custom($page->ID);
    	$max_person = isset( $values['max_person'] ) ? esc_attr( $values['max_person'][0] ) : '';
    	$room_bed = isset( $values['room_bed'] ) ? esc_attr( $values['room_bed'][0] ) : '';
    	$room_size = isset( $values['room_size'] ) ? esc_attr( $values['room_size'][0] ) : '';
    	$features = isset( $values['room_features'] ) ? esc_attr( $values['room_features'][0] ) : '';
    	$policies = isset( $values['room_policies'] ) ? esc_attr( $values['room_policies'][0] ) : ''; 
    
        wp_nonce_field( 'metabox1_nonce', 'metabox1_nonce' ); 
    
    ?>
    	<div>
    		<label for="person_per_room"><?php _e('Max Person Per Room');?></label><br/>
    		<p><input name="max_person" id="person_per_room" value="<?php echo $max_person ?>"></p>
    	</div>
    
    	<div >
    		<label for="room_bed"><?php _e('Room bed(s)');?></label><br/>
    		<p><input name="room_bed" id="room_bed" value="<?php echo $room_bed?>"></p>
    	</div>
    
    	<div>
    		<label for="room_size"><?php _e('Room size');?></label><br/>
    		<p><input name="room_size" id="room_size" value="<?php echo $room_size?>"></p>
    	</div>
    	<div>
    		<label for="features"><?php _e('Features(leave this field blank if you don

    t show the features tab for this room)’)?></label>
    <p><textarea style=”” cols=”90″ rows=”5″ name=”room_features” id=”room_features” value=”<?php //echo $features;?>”></textarea></p>
    </div>
    <div>
    <label for=”policies”><?php _e(‘Policies(leave this field blank if you don`t show the policies tab for this room)’)?></label>
    <p><textarea cols=”90″ rows=”5″ name=”room_policies” id=”room_policies” value=”<?php echo $policies;?>”></textarea></p>
    </div>
    <?php
    }

    function metabox1_save($page)
    {
    if( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) return;
    if( !isset( $_POST[‘metabox1_nonce’] ) || !wp_verify_nonce( $_POST[‘metabox1_nonce’], ‘metabox1_nonce’ ) ) return;
    if( !current_user_can( ‘edit_posts’ ) ) return;

    if( isset( $_POST[‘max_person’] ) )
    update_post_meta( $page, ‘max_person’, esc_attr( $_POST[‘max_person’]) );

    if( isset( $_POST[‘room_bed’] ) )
    update_post_meta( $page, ‘room_bed’, esc_attr( $_POST[‘room_bed’]) );

    if( isset( $_POST[‘room_size’] ) )
    update_post_meta( $page, ‘room_size’, esc_attr( $_POST[‘room_size’]) );

    if(isset($_POST[‘room_features’]))
    update_post_meta($page,’room_features’,esc_attr($_POST[‘room_features’]));

    if(isset($_POST[‘room_policies’]))
    update_post_meta($page,’room_policies’,esc_attr($_POST[‘room_policies’]));
    }

    except features and polices not showing after updating but i am getting the front page all the content features and policies

    Abhishek Kumar

    (@abhishekfdd)

    In your mentabox1_rendering function call meatball values by using get_post_meta e.g.;

    $features = get_post_meta($page->ID,'room_features',TRUE);

    and here<p><textarea style="" cols="90" rows="5" name="room_features" id="room_features" value="<?php //echo $features; ?>"></textarea></p>

    remove // ie use
    <p><textarea style="" cols="90" rows="5" name="room_features" id="room_features" value="<?php echo $features; ?>"></textarea></p>

    Thread Starter dileepraja

    (@dileepraja)

    i got the problem this will work <textarea cols=”90″ rows=”5″ name=”room_features” id=”room_features”><?php echo $features?></textarea>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘metabox’ is closed to new replies.