Here’s some neat code that will enable the TinyMCE rich text editor within your excerpts box. You can now insert links and other HTML into your excerpts.
This code should be inserted into your theme’s functions.php, or better still create a plugin out of it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
function tinymce_excerpt_js(){ ?> <script type="text/javascript"> jQuery(document).ready( tinymce_excerpt ); function tinymce_excerpt() { jQuery("#excerpt").addClass("mceEditor"); tinyMCE.execCommand("mceAddControl", false, "excerpt"); tinyMCE.onAddEditor.add(function(mgr,ed) { if(ed.id=="excerpt"){ ed.settings.theme_advanced_buttons2 =""; ed.settings.theme_advanced_buttons1 = "bold,italic,underline,seperator,justifyleft,justifycenter,justifyright,separator,link,unlink,seperator,pastetext,pasteword,removeformat,seperator,undo,redo,seperator,spellchecker,"; } }); } </script> <?php } add_action( 'admin_head-post.php', 'tinymce_excerpt_js'); add_action( 'admin_head-post-new.php', 'tinymce_excerpt_js'); function tinymce_css(){ ?> <style type='text/css'> #postexcerpt .inside{margin:0;padding:0;background:#fff;} #postexcerpt .inside p{padding:0px 0px 5px 10px;} #postexcerpt #excerpteditorcontainer { border-style: solid; padding: 0; } </style> <?php } add_action( 'admin_head-post.php', 'tinymce_css'); add_action( 'admin_head-post-new.php', 'tinymce_css'); function prepareExcerptForEdit($e){ return nl2br($e); } add_action( 'excerpt_edit_pre','prepareExcerptForEdit'); |
Found via http://haet.at/add-tinymce-editor-wordpress-excerpt-field/
If you enjoyed this post, make sure to subscribe to WPMayor’s RSS feed.
Is there a way to DISABLE TinyMCE (Advanced) for WooCommerce Shoprt Description (like excerpt field) ?