Created
February 13, 2015 07:20
-
-
Save Irfan-Ansari/a4839270e228f1a1d123 to your computer and use it in GitHub Desktop.
How to add wysiwyg editor in Wordpress meta box
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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