Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ControlledChaos/8d5488678a30831730b1b1922bcb59bb to your computer and use it in GitHub Desktop.
Save ControlledChaos/8d5488678a30831730b1b1922bcb59bb to your computer and use it in GitHub Desktop.
WordPress function to add the TinyMCE WYSIWYG editor to any custom field of type 'Textarea'
// important: note the priority of 99, the js needs to be placed after tinymce loads
// important: note that this assumes you're using http://wordpress.org/extend/plugins/verve-meta-boxes/
// to create the textarea - otherwise change your selector
function admin_add_wysiwyg_custom_field_textarea()
{ ?>
<script type="text/javascript">/* <![CDATA[ */
jQuery(function($){
var i=1;
$('.verve_meta_box_content textarea').each(function(e)
{
var id = $(this).attr('id');
if (!id)
{
id = 'customEditor-' + i++;
$(this).attr('id',id);
}
tinyMCE.execCommand('mceAddControl', false, id);
});
});
/* ]]> */</script>
<?php }
add_action( 'admin_print_footer_scripts', 'admin_add_wysiwyg_custom_field_textarea', 99 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment