Monday, 23 December 2013

How to add wysiwyg editor in Wordpress meta box


How to add wysiwyg editor in Wordpress meta box

Add below code into your function.php file :

// Custom meta box
add_action( 'add_meta_boxes', 'add_new_metabox' );
function add_new_metabox()
    {
        add_meta_box('custom_fields', 'Custom Fields', 'my_custom_fields');
    }

function my_custom_fields( $post )
    {
         $includes =  get_post_meta($_GET['post'], 'includes' , true ) ;
 wp_editor( htmlspecialchars_decode($includes), 'mettaabox_ID_stylee', $settings = array('textarea_name'=>'includes','media_buttons' => false) );
   }

function save_my_postdata( $post_id )
{                
    if (!empty($_POST['includes']))
        {
$datta=htmlspecialchars($_POST['includes']);
update_post_meta($post_id,'includes',$datta );
        }
}

No comments: