5 votes
Accepted

WooCommerce Description and Short Description <p> tags removal

So, I realized I was using the actual object in the template to call the description $product-get_description(). If you're experiencing this issue, then you can wrap this in a wpautop(), or you can do ...
macondo_buendia's user avatar
4 votes

remove empty paragraphs from the_content?

Same approach than 2 answers before me, but an updated regex, because his didn't work for me. the regex: /<p>(?:\s|&nbsp;)*?<\/p>/i (non capture group looking for any number of either ...
kater louis's user avatar
4 votes

How do I disable wpautop for a specific block?

@morgan-estes Great solution but it i think it should be better to add_filter in else so the next block or content gets filter with WPAUTOP /** * Try to disable wpautop inside specific blocks. * * ...
Abbas Arif's user avatar
3 votes

How do I disable wpautop for a specific block?

I've found that I can use the render_block filter to disable wpautop() when a block gets rendered. It looks to me that this only affects the immediate block, as the filter gets re-enabled from ...
Morgan Estes's user avatar
  • 1,525
3 votes

Is there un-wp_autop function?

I also needed a way to do this but wasn't happy with any existing solutions so decided to make one. Hope it helps someone. <?php /** * Replaces paragraph elements with double line-breaks. * * ...
Frankie Jarrett's user avatar
2 votes

Remove wpautop from shortcode content / remove whitespace in buffering

There is a WordPress function available that does this job nicely. There isn't any need to use a custom function or a plugin to do this. Just use the shortcode_unautop($pee) function to remove ...
Eh Jewel's user avatar
  • 845
2 votes

Shortcode from a widget is wrapped in unwanted <p> element

This is a known issue since years. Please have a look at Wordpress Ticket. As others maybe mentioned before, there is Plugin to fix this issue. It is called "Shortcode Empty Paragraph Fix". Its not ...
evavienna's user avatar
  • 131
2 votes

Why does WP not like my <a> container?

I think it's safe to say that wpautop() is a basket case without hurting anyone's feelings, but I wouldn't remove & add it at a different priority as that just makes things worse, as demonstrated (...
bonger's user avatar
  • 4,381
2 votes

Remove wpautop from specific shortcodes only

Well, there is a script out there. The author claims that it removes the wpautop form individual specific shorcodes. You'll find it here. Add this to your functions.php or your plugin like below- // ...
CodeMascot's user avatar
  • 4,527
2 votes

How to disable auto-p in WordPress?

In your child theme's functions.php, try something like this: remove_filter( 'the_content', 'wp_autop' ); Note that this may have unintended side-effects, and will definitely have an effect on how ...
phatskat's user avatar
  • 3,134
1 vote

How to call a PHP function in WordPress when you click on a button?

Take a look at AJAX in Plugins which uses admin-ajax.php. This is a way for you to interact with WordPress via a javascript request to WordPress.
MikeNGarrett's user avatar
  • 2,661
1 vote

Shortcodes within the sidebar text/html widget: How to preserve the raw HTML output of the shortcode?

Try this code: add_filter( 'wp_targeted_link_rel', '__return_false', 9999 ); function widget_text_replace($text) { $search = array('rel="noopener"'); $replace = array(''); $text = ...
Bhupen's user avatar
  • 734
1 vote

Remove empty p-Tags in Shortcode content before non p-Tags

The empty p tag in the developer console means that you have other HTML being outputted inside it, which shouldn't be there. i.e the H5 tag for the heading. This is because "do_shortcode" uses the ...
Warwick's user avatar
  • 376
1 vote

Images that copy code to clipboard when you click on them

I think that clipboard.js is your best bet to what you're looking for. Install that script, then just change your img to <img src="..." data-clipboard-text="..."> And you should be good to ...
Paul Elrich's user avatar
1 vote

remove_filter( 'the_content', 'wpautop' ); is not working for me

You can achieve this much easier with css (escpecially for wp-ers who dont have access to edit plugins): <style> p:empty{ height: 0; margin: 0; padding: 0; } </style>
ekerner's user avatar
  • 144
1 vote

Extra paragraph tags in an enclosing shortcode

OK, it seems someone has trod this path and there is in fact.... shortcode_unautop() Job Done. It looks elegant in the editor and works in the output. The shortcode now looks like this; function ...
Chris Pink's user avatar
1 vote
Accepted

Selectively remove empty line after line change

gdaniel answered the bulk of question with this comment: Every time you type Enter (the return character) the editor creates a new paragraph <p>my content</p>, the alternative is to ...
Dave Romsey's user avatar
  • 17.7k
1 vote

New method to disable wpautop after WP 4.3?

This works well. It's about the priority of the hook : add_filter( 'the_content', 'njengah_remove_autop', 0 ); function njengah_remove_autop($content) { // remove autop ...
NJENGAH's user avatar
  • 379
1 vote

Raw output (preventing wpautop)

Late to the party, but this plugin, Toggle wpautop, lets you selectively disable whether you want WP to butcher your content on pages or posts, and works on WP 4.9 (current version as of this answer).
Mac's user avatar
  • 151

Only top scored, non community-wiki answers of a minimum length are eligible