Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

When I enter content in posts/pages' WYSIWYG editor, I do not get <p> when ending paragraphs, just &nbsps. If I manually place <p></p> in the HTML mode, they are stripped as soon as I switch to 'visual' mode. This is repeated in several sites (I thought it was the theme but it isn't).

I have read dozens of topics and answers, but none solve my problem. I tried add/remove wpautop in my functions.php file but nothing helps.

I do not want to use a tinymce plugin.

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

I have done extended research and found the answer - I am now using a hook on 'tiny_mce_before_init'.

Based on other answers (special thanks to answer #2 @Chip Bennett), I have used the following code in my functions.php to secure the paragraph breaks (in the editor HTML mode they show as &nbsp but become paragraphs on the front-end):

function 59772_tinymce_config( $init ) {
   // Don't remove line breaks
   $init['remove_linebreaks'] = false; 
   // Convert newline characters to BR tags
   $init['convert_newlines_to_brs'] = true; 
   // Do not remove redundant BR tags
   $init['remove_redundant_brs'] = false;

   // Pass $init back to WordPress
   return $init;
}
add_filter('tiny_mce_before_init', '59772_tinymce_config');

You can find on the tinyMCE site the different possible configurations.

share|improve this answer
    
function name shouldnt start with numbers. It throws error. –  ewroman Apr 21 at 19:31
add comment

you could also say that TinyMCE is integrated with WordPress and the HTML editor strips out some characters in favour &nbsp ... this was originally for security and the belief that we didnt need <br> or <p> anymore

share|improve this answer
    
oh how wrong they were....lol –  Aliyah Jul 26 '12 at 21:18
    
@Aliyah I dont think they'll add it back again. It's been that way for years. FWIW ... I never knew CKEditor had been packaged for WordPress and I guess it is free? –  Damien Jul 26 '12 at 21:46
    
Yea its in the WP plugins directory in the link I gave –  Aliyah Jul 26 '12 at 21:49
    
wait a sec lol..is that your answer? –  Aliyah Jul 26 '12 at 21:59
    
@Damien - that's a good explanation, any solutions? –  Nona Man Jul 27 '12 at 9:28
show 1 more comment

You can try the CKEditor

Wordpress CKEditor

share|improve this answer
    
@aliyah- isn't there some code we can use? I don't like using plugins, because you never know how they'll affect other things. –  Nona Man Jul 27 '12 at 9:28
    
@NonaMan Not every plugin has adverse effects on the site. Try it out and see if it solves your problem. This is simply an enhanced WYSIWYG editor plugin. It may or may not solve your problem, never hurts to try. You can always disable it. I'm using it now and the site runs smoothly. It doesnt make any serious changes. –  Aliyah Jul 27 '12 at 18:47
    
This works and provides the editor with the ability to keep the paragraph tags. Thankyou! I do wish someone can write a function that hooks onto the editor and changes the 'nbsp' to paragraph tags. –  Nona Man Jul 31 '12 at 4:48
    
@NonaMan Me too lol –  Aliyah Aug 1 '12 at 22:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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