Problem with saving data from meta box (1 post)

  1. Inogo
    Posted 6 years ago #

    Hi there

    I have a text area in a meta box on the edit page screen. It doesn't work very well :)
    First time I save the page, it works perfect. But when I change the text, the changes arent saved. And if I remove the text, the text stays there...

    This is how I handle the saves/updates... Can someone see what Im doing wrong?

    $meta_value1 = get_post_meta( $post_id, 'box_1', true );
    	$new_meta_value1 = stripslashes( $_POST['box-1-content'] );
    	if ( $new_meta_value1 && '' == $meta_value1 )
    		add_post_meta( $post_id, 'box_1', $new_meta_value1, true ) or update_post_meta( $post_id, 'box_1', $new_meta_value1 );
    	elseif ( $new_meta_value1 != $meta_value1 )
    		update_post_meta( $post_id, 'box_1', $new_meta_value1 );
    	elseif ( '' == $new_meta_value1 && $meta_value1 )
    		delete_post_meta( $post_id, 'box_1', $meta_value1 );

Topic Closed

This topic has been closed to new replies.

About this Topic