I see that in other sites that use wordpress this does not happen, so I would like to know how to space without creating a blank paragraph or a &nbsp ?

As you can see in the image, in each space a blank paragraph is created

enter image description here

And in the_excerpt too

enter image description here

My site if you want to see more examples


The answers of Wordpress tinymce prints empty P tag and break html format did not resolve mine

The paragraphs remain blank and &nbsp keeps appearing

  • Use this: wordpress.stackexchange.com/a/190036
    – Fayaz
    Feb 24, 2017 at 19:44
  • Possible duplicate of Wordpress tinymce prints empty P tag and break html format
    – Fayaz
    Feb 24, 2017 at 19:45
  • @Fayaz The answers of of that question did not resolve mine Feb 24, 2017 at 20:33
  • What Plugin / CODE are you using to create meta description tags, i.e. <meta name="description" content="..."?
    – Fayaz
    Feb 24, 2017 at 21:26
  • @Fayaz i'm getting the_excerpt if is_single page and using an advanced custom field for the other pages. But the problem is the blank paragraphs in the content, the excerpt is with these &nbsp because it is generated through the content Feb 24, 2017 at 21:45

2 Answers 2


Judging from your site's content and the comments, you may try using the following CODE in your theme's functions.php file. It'll remove empty <p>&nbsp;</p> tags from post content:

add_filter( 'the_content', 'wpse_257854_remove_empty_p', PHP_INT_MAX );
add_filter( 'the_excerpt', 'wpse_257854_remove_empty_p', PHP_INT_MAX );
function wpse_257854_remove_empty_p( $content ) {
    return str_ireplace( '<p>&nbsp;</p>', '', $content );

However, after it removes the empty <p>&nbsp;</p> tags, paragraphs in your site's post content will collapse with each other. To maintain the visual gap between paragraphs, you may use the following CSS:

.conteudo-noticia p {
    padding-bottom: 15px;

If nbsp; within meta description tags are coming from content (or excerpt) & the plugin used to capture them are handling the content as it should (according to WordPress loop standard), then after using the above CODE, meta tags should be fixed as well.

Note: After making the above changes, please make sure you clear browser cache properly and clear any server cache (from cache plugin, web server etc.) if present before testing the result.


If you don't want to control paragraph gap with CSS padding, then there is a slightly different CODE you may try:

add_filter( 'the_content', 'wpse_257854_remove_empty_p', PHP_INT_MAX );
add_filter( 'the_excerpt', 'wpse_257854_remove_empty_p', PHP_INT_MAX );
function wpse_257854_remove_empty_p( $content ) {
    return str_ireplace( '<p>&nbsp;</p>', '<br>', $content );

This CODE, instead of removing the empty p tags, replaces them with line breaks <br>. So this way you can control paragraph gaps from within the editor without having empty p tags with &nbsp;.

  • This code partially solves the question. What I want is to be able to manipulate the spacing with the editor and not with a padding or margin. I think this is the wordpress default (or I may be wrong) but for some reason the editor is generating these & nbsp Feb 24, 2017 at 23:40
  • Updated with CODE that doesn't need CSS to control paragraph gaps.
    – Fayaz
    Feb 24, 2017 at 23:55
  • It worked perfectly, I also used a br { Line-height: 140%;} for a bigger space Feb 25, 2017 at 0:58
function add_necessary_functions() {

    function read_more($limit){
        $post_content = explode(" ", get_the_content());
        $less_content = array_slice($post_content, $limit);
        echo implode(" ", $less_content);

You Can create your won read more function with this. And use $limit as the counter that how many word you want to display.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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