Support » Plugins and Hacks » Black Studio TinyMCE Widget » [Resolved] Adds unwanted p tag

[Resolved] Adds unwanted p tag

  • This is probably something that’s obvious, but…

    Since, my html tags are specified elsewhere, I don’t need the default p tag that shows in the HTML view of the widget. If I remove this tag, switch to WYSIWYG, and go back to the HTML view, the p tag returns.

    Can I add an option under WYSIWYG Formatting drop down to “none” and/or remove the default formatting from within the plugin files?


Viewing 1 replies (of 1 total)
  • Plugin Author Marco Chiesi


    Unfortunately the automatic p tag addition is a native feature of the editor.
    I can suggest 2 alternative solutions:

    1) Adjust your css for p tags inside widgets accordingly
    If you set the p tags with no margin and padding it shouldn’t mess your layout.

    .textwidget p {
      margin: 0;
      padding: 0;

    Depending on your css, you may need to reset also a few additional properties.

    2) Remove phisically the p tag via filter hook
    You may use the filter widget_text to remove the p tags from the text.

    add_filter('widget_text', 'my_widget_text');
    function my_widget_text($text, $instance) {
        //remove any new lines already in there
        $text = str_replace("\n", "", $text);
        //remove all <p>
        $text = str_replace("<p>", "", $text);
        //replace <br /> with \n
        $text = str_replace(array("<br />", "<br>", "<br/>"), "\n", $text);
        //replace </p> with \n\n
        $text = str_replace("</p>", "\n\n", $text);       
        return $text;

    Note: the above code has not been tested and it’s partially taken from here.

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] Adds unwanted p tag’ is closed to new replies.
Skip to toolbar