Support » Fixing WordPress » Disabling wpautop from Twenty Sixteen

  • Resolved Ann N



    I wish to embed javascript in some of my pages for interactive charts and have page templates that enqueue the scripts I need in the header, as I understand that is best practice. But, I need to have javascript tags in the page content as well and haven’t found a reliable way to keep WordPress from sandwiching my javascript tags. The paragraph tags are being inserted between javascript tags even when there is no space. For example,

    <div id = 'chart3a683aa64ea' class = 'rChart nvd3'></div><script type='text/javascript'>


    <div id = 'chart3a683aa64ea' class = 'rChart nvd3'></div><strong><p></strong><script type='text/javascript'>

    when the page is rendered in html.

    Here’s what I’ve tried to date. I’m hoping I’ve not overlooked something simple.

    1. I use a child theme and in the functions.php, I have the following commands in the last two lines before the closing <?> : remove_filter( ‘the_content’, ‘wpautop’,99 ); and remove_filter( ‘the_excerpt’, ‘wpautop’,99 );

    2. I limit the use of javascript in pages by using a page template to enqueue the java libraries and styles I need (e.g., nv.d3.css, d3.v3.min.js, fisheye.js). The wp_enqueue_style and wp_enqueue_script are inserted before the get_header() command.

    3. I activated the Raw HTML plugin and make sure the box, “Disable automatic paragraphs” is checked and that my page template is selected in the page attributes.

    4. I edit all pages in the text editor and do not go back and forth between text and visual editors.

    5. I use use Ruben Afonso’s Wp-D3 plugin for sites that don’t rely on Morris and other javascript libaries (this has been successful).

    Thank you to anyone willing to help.

    If examples will help,
    I have one page where the insertion of javascript has not been a problem: This page renders just fine.

    However, this page,, seems to draw WP <p> tags like bees to honey.


Viewing 3 replies - 1 through 3 (of 3 total)
  • My apologies. The example of the <p> tag insertion should read:


    <div id = ‘chart3a683aa64ea’ class = ‘rChart nvd3′></div><p><script type=’text/javascript’>


    I’m going to go ahead and close this thread. I think the problem I’m having with my page is that I’m calling a jquery function in the body and need to figure out a workaround.

    Try this in your functions file

    remove_filter( ‘the_content’, ‘wpautop’ );

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Disabling wpautop from Twenty Sixteen’ is closed to new replies.