Skip to content

Instantly share code, notes, and snippets.

@jaredwilli
Created December 11, 2010 02:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredwilli/737093 to your computer and use it in GitHub Desktop.
Save jaredwilli/737093 to your computer and use it in GitHub Desktop.
Add TinyMCE Metabox in WordPress
function additional_info() {
global $post;
$custom = get_post_custom($post->ID);
$additional_info = $custom["additional_info"][0];
// this adds an extra tinymce field
?>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#additional_info_textarea").addClass("mceEditor");
if ( typeof( tinyMCE ) == "object" && typeof( tinyMCE.execCommand ) == "function" ) {
tinyMCE.execCommand("mceAddControl", false, "additional_info_textarea");
}
});
</script>
<style type="text/css">#additional_info_textarea_ifr { border:1px solid #DFDFDF; }</style>
<p><label style="display:none;">Any additional information:</label><br />
<textarea cols="50" rows="5" id="additional_info_textarea" name="additional_info"><?php echo $additional_info; ?></textarea></p>
<?php
}
// enable new wysiwyg features
add_filter('mce_css', 'my_editor_style');
function my_editor_style($url) {
if ( !empty($url) )
$url .= ',';
// Change the path here if using sub-directory
$url .= trailingslashit( get_stylesheet_directory_uri() ) . 'editor-style.css';
return $url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment