Disabling wpautop from Twenty Sixteen
-
Hello,
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'>
becomes
<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.
P.S.
If examples will help,
I have one page where the insertion of javascript has not been a problem:
https://www.d8aism.com/?page_id=144 This page renders just fine.However, this page, https://www.d8aism.com/?page_id=254, seems to draw WP <p> tags like bees to honey.
Ann
- The topic ‘Disabling wpautop from Twenty Sixteen’ is closed to new replies.