Skip to content
Public Ticket #18037

Disable automatic P tags

Conversation thread

PenciDesign Supporter replied

Staff Reply

Hi,

Please try to replace it with this code:

add_filter( 'the_content', 'wpse_remove_autop_for_posttype', 0 );
function wpse_remove_autop_for_posttype( $content ) {
    if ( 'post' === get_post_type() ) {
        remove_filter( 'the_content', 'wpautop' );
    }
    return $content;
}

Regards,
PenciDesign.



PenciDesign Supporter replied

Staff Reply

Hi,

Can you send me your site login information in a private reply? I need to log in and check your post setting.

Regards,
PenciDesign.


jordi_ceballos Ceballos replied

Customer Reply

Sorry, I don't know why, but it does not seem to have any effect.  I installed the Code Snippets plugin, I created the snipped with your suggested content (see attached screenshot) and it is currently active.  But if I go to a post, go to HTML editor and copy some text, as soon as I press "Exit code editor", my text is automatically surrounded by P tags.  I understood that this is exactly what this snippet should prevent, right?

Any idea of what I have done wrong?

Thanks

PenciDesign Supporter replied

Staff Reply

Hi,

Please install the CodeSnippet plugin, then create a new snippet with the following content:

remove_filter( 'the_content', 'wpautop' );
// OR
remove_filter( 'the_excerpt', 'wpautop' );

Regards,
PenciDesign.


jordi_ceballos Ceballos started the conversation

Conversation Start

The wordpress editor is automatically adding P tags into my HTML posts, and I would like to disable it in order to have a better control over the HTML generated.

Could you please tell me how to disable this?  

Thanks

Want to join this conversation or access attachments? Sign in first.