After i add these codes to functions.php:


function childtheme_mce_btns2($orig) {
return array('formatselect','styleselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', 'removeformat', '|', 'media', 'charmap', '|', 'outdent', 'indent', '|', 'undo', 'redo', 'wp_help' );
add_filter( 'mce_buttons_2', 'childtheme_mce_btns2', 999 );

function childtheme_tiny_mce_before_init( $init_array ) {
$init_array['theme_advanced_styles'] = "box note=box_note;box info=box_info;box warning=box_warning;box download=box_download";
return $init_array;
add_filter( 'tiny_mce_before_init', 'childtheme_tiny_mce_before_init' );

I had a style drop down menu in Wordpress Visual Editor with "box note,box info,box warning,box download" options. I created editor-style.css so i got css support for those classes in visual editor.

If i select "box note" style example, wordpress putting it as <p class="box_note"></p> Problem is when i push enter button for line breaking, wordpress putting <p></p> automatically.

Basically how can i change those styles using <div> <span> or anything except <p>?

Update: I create some screenshots for you. This is when i select style from style list: http://www.unsalkorkmaz.com/sorun/sorun1.jpg This is when i push enter button for line breaking: http://www.unsalkorkmaz.com/sorun/sorun2.jpg Wordpress basically creating different <p>

I tried;

remove_filter('the_content', 'wpautop');
remove_filter('the_content', 'wptexturize');
remove_filter('the_content', 'convert_smilies');
remove_filter('the_content', 'convert_chars');

before i create this question but its not the solution seems.

Update 2: Well.. I tried shift+enter to line-break and it works! So i dont know what is difference with enter vs shift+enter in TinyMCE but i want shift+enter function as default of enter button.


2 Answers 2


If you always want <br/> instead of <p> for newlines you can change the TinyMCE configuration:

forced_root_block: false,
force_br_newlines: true,
force_p_newlines : false,

I think you cannot do this based on the context (use <br/> when in class="box_note", <p> otherwise), but it is an interesting question for the TinyMCE forum. Shift+Enter is indeed the standard way to differentiate between paragraph and line endings.

  • i found those too but when i try to add these as "wordpress" way with filters without editing core, they just didnt work.. can you write wordpress code working? maybe i can found what i am doing wrong Nov 26, 2010 at 21:55
  • basically problem was wordpress adding "" to false/true sections Nov 26, 2010 at 21:56
  • @Ünsal: Indeed, stupid WordPress does not accept non-string values. Unless you trick it.
    – Jan Fabry
    Nov 26, 2010 at 22:24
  • i accept your answer mate. thanks a lot. esspecially your comment link answer is the trick Nov 27, 2010 at 3:23
  • @Ünsal: Good news: in WP 3.1 boolean values can pass without being wrapped in quotes, because of an extra check when writing the JS config variable.
    – Jan Fabry
    Nov 27, 2010 at 19:47

Is this your quesion:

  1. http://www.orphicpixel.com/common-wordpress-annoyance/
  2. Line breaks not showing up properly
  3. How can I improve the line break handling in the WYSIWYG editor?
  4. Why is WordPress WYSIWYMG and how do I make it WYSIWYG?


  • i updated question.. i am talking about TinyMce live edit, those problems are "after" save post seems. Thanks for help btw :) Nov 20, 2010 at 22:16
  • And.. i tried Tiny MCE Advanced with "Stop Removing the <p>and <br/> tags when saving and show them in the HTML editor" Nov 20, 2010 at 22:36
  • and.. update 2: I tried shift+enter to line-break and it works! So i dont know what is difference with enter vs shift+enter in TinyMCE but i want shift+enter function as default of enter button. Nov 20, 2010 at 22:43
  • The problem is that the content replacement is hard-coded into the editor javascript, when you switch editor modes(visual/html) you envoke a replacement script that runs over the content, which can't account for your custom styles..
    – t31os
    Nov 20, 2010 at 23:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.