Skip to content

Instantly share code, notes, and snippets.

@TeemuSuoranta
Created October 18, 2019 06:57
Show Gist options
  • Select an option

  • Save TeemuSuoranta/16accb52a24f1f4dd0d22df701047d76 to your computer and use it in GitHub Desktop.

Select an option

Save TeemuSuoranta/16accb52a24f1f4dd0d22df701047d76 to your computer and use it in GitHub Desktop.

Revisions

  1. TeemuSuoranta created this gist Oct 18, 2019.
    17 changes: 17 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    <?php
    /**
    * Remove empty paragraphs
    *
    * @param string $content the HTML markup of content
    *
    * @return string the HTML markup of content
    */
    add_filter('the_content', function ($content) {

    if (!is_admin()) {
    $content = str_replace('<p></p>', '', $content);
    $content = str_replace('<p>&nbsp;</p>', '', $content);
    }
    return $content;

    });