Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Irfan-Ansari/a4839270e228f1a1d123 to your computer and use it in GitHub Desktop.
Save Irfan-Ansari/a4839270e228f1a1d123 to your computer and use it in GitHub Desktop.
How to add wysiwyg editor in Wordpress meta box
<?php
add_action( 'add_meta_boxes', 'adding_new_metaabox' );
function adding_new_metaabox()
{
add_meta_box('adsexcerptid', 'Ads Content', 'my_output_function');
}
function my_output_function( $post )
{
$settings = array(
'quicktags' => array( 'buttons' => 'em,strong,link' ),
'textarea_name' => 'ads-excerpt',
'quicktags' => true,
'tinymce' => true
);
wp_editor( htmlspecialchars_decode(get_post_meta($_GET['post'], 'ads_excerpt_content' , true )), 'mettaabox_ID_stylee', $settings );
}
function save_my_postdata( $post_id )
{
if (!empty($_POST['ads-excerpt']))
{
update_post_meta($post_id, 'ads_excerpt_content', htmlspecialchars($_POST['ads-excerpt']) );
}
}
add_action( 'save_post', 'save_my_postdata' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment