Stop certain classes showing up in TinyMCE Advanced Style dropdown

This should be what you’re looking for – put this code into your theme’s functions.php file: add_filter( ‘tiny_mce_before_init’, ‘yourprefix_tiny_mce_before_init’ ); function yourprefix_tiny_mce_before_init( $init_array ) { // filter styles: $init_array[‘theme_advanced_styles’] = “your_style=your_class”; // filter formats: $init_array[‘theme_advanced_blockformats’] = “p,h3,h4,h5”; return $init_array; } This way the only style that will be displayed is your_style. The 3rd line is … Read more

Force TinyMCE editor’s “Toolbar Toggle” to be automatically chosen & expanded

Add below function in your activated theme’s functions.php file. function changeMceDefaults($in) { // customize the buttons $in[‘theme_advanced_buttons1’] = ‘bold,italic,underline,bullist,numlist,hr,blockquote,link,unlink,justifyleft,justifycenter,justifyright,justifyfull,outdent,indent’; $in[‘theme_advanced_buttons2’] = ‘formatselect,pastetext,pasteword,charmap,undo,redo’; // Keep the “kitchen sink” open $in[ ‘wordpress_adv_hidden’ ] = FALSE; return $in; } add_filter( ‘tiny_mce_before_init’, ‘changeMceDefaults’ );

How can i add some static text above the editor?

The best way would be using JavaScript to inject the element. Here’s the gist of the markup for that page: <div id=”poststuff”> <div id=”post-body” class=”metabox-holder columns-2″> <div id=”post-body-content”> <div id=”titlediv”> … other stuff … </div> <div id=”postdivrich” class=”postarea”> … other stuff … </div> </div> </div> </div> The titlediv is the title. The postdivrich is the … Read more

How to edit posts with the new wp_editor api?

For the sake of completeness, I am going to post an answer based on the solution you edited in your question. $post = get_post( $post_id, ‘OBJECT’ ); wp_editor( esc_html( $post->post_content ), ‘textarea01’, $settings ); This would escape the HTML too so if you are editing a post you might want to replace the last line … Read more

Disable WYSIWYG editor only when creating a page

The best way to do this is by adding ‘user_can_richedit’ filter, like so: add_filter( ‘user_can_richedit’, ‘patrick_user_can_richedit’); function patrick_user_can_richedit($c) { global $post_type; if (‘page’ == $post_type) return false; return $c; } Hope it’s useful 😉

Avoid converting “>” to >

Filtering the_content function wpse72941_content_filter( $content ) { $new_content=””; foreach( preg_split( ‘/((\r?\n)|(\r\n?))/’, $content ) as $line ) { $new_content .= preg_replace( ‘/^&gt;/’, ‘>’, $line ) . ‘\r\n’; } return $new_content; } add_filter( ‘the_content’, ‘wpse72941_content_filter’, 1 ); I don’t know your markdown plugin – for the above approach, I have assumed that the markdown is interpreted after … Read more

Adding a rich text editor to Excerpt

Just replace the default output. Make sure you unescape the excerpt before you send it to the editor: add_action( ‘add_meta_boxes’, array ( ‘T5_Richtext_Excerpt’, ‘switch_boxes’ ) ); /** * Replaces the default excerpt editor with TinyMCE. */ class T5_Richtext_Excerpt { /** * Replaces the meta boxes. * * @return void */ public static function switch_boxes() { … Read more

Editor removes tags

I had problems with TinyMCE Advanced. I struggled with this for a while. Finally discovered a simple solution – Use Shortcodes! Place this code into functions.php and enter [br] wherever you want a br tag to appear. add_shortcode(“br”, “br_tag”); function br_tag(){ return(“<br/>”); }