WordPress has a useful feature called wpautop (WordPress Auto Paragaphs) that automatically adds paragraphs and line breaks when WordPress editor is used in Text view. There may be times when you need to add a lot of HTML code in the Page editor and find that WordPress is messing up the output by adding unwanted p
tags in the rendered HTML on the front end.
It is possible to disable wpautop from specific Page(s) in Genesis by adding the following in child theme’s functions.php:
// Disable wpautop on selected Page(s).
add_action( 'genesis_entry_header', function () {
// if this is not FAQs or Team Page, abort.
if ( ! is_page( array( 'faqs', 'team' ) ) ) {
return;
}
remove_filter( 'the_content', 'wpautop' );
} );
where faqs and team are the slugs of Pages on which wpautop should be disabled.
Source: https://grahamwalters.me/lab/disable-wpautop-on-specific-postspages/#comment-1667681659
Hi Sridhar! Great snippet! I made it a label with just the remove_filter line in Dynamik so I can choose it for posts and/or pages whenever I need it. Might be worth an addition to this article? However – thanks much, saves me lots of headaches!