Join the Soledad Facebook Users Group here
for Share, assistance, discussion, and Updates related to Soledad WordPress Theme.

If you can't create a new ticket - you can send us an email via our contact form and we will get back to you.

Okay
  Public Ticket #2874584
Disable automatic P tags
Closed

Comments

  • jordi_ceballos started the conversation

    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

  •  2,492
    PenciDesign replied

    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 replied

    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

  •  2,492
    PenciDesign replied

    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 replied privately
  •   jordi_ceballos replied privately
  •  2,492
    PenciDesign replied

    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.



  •   jordi_ceballos replied privately
  •  2,492
    PenciDesign replied

    Hi,

    In this case, the p tag was inserted from the post editor, so please try to edit your post on the Classic Editor: https://wordpress.org/plugins/classic-editor/

    Regards,
    PenciDesign.


  •   jordi_ceballos replied privately