Archived topic
How to eliminate automatic tag
1 reply · Started by Giorgio on August 25, 2021
Hi,
I want to insert a javascript script inside a post, but also using the code editor after I have saved, the <p> tags are inserted at the beginning and at the end of the script.
I also tried to insert the following code inside the function.php file, but it doesn't work for me:
remove_filter ('the_content', 'wpautop');
I have wordpress 5.8 and latest version of generatepress 3.0.4
Is there any way to fix?
Thanks
Hi there,
If you're using the Block Editor then add the <script></script> to a HTML Block. This will keep the formatting.
Personally though, i would recommend using a Hook Element to add the script to the wp_footer and set the Display Rules for that post. This keeps the script from being saved in your post content, outputs the script in the 'correct' place, and can be easily updated, edited and added to other posts ( if needed ) from one place.
Its always best to try and keep content and codes separate :)