You should use wp_enqueue_script for your javascript files instead of adding the code directly into the post content.
ps:
You can check out the callbacks on the the_content
filter, using
add_action('wp_footer',function(){
global $wp_filter;
printf('<pre>%s</pre>',print_r( $wp_filter['the_content'],true));
});
to display them in the footer part of your theme. Then you will see callbacks like
wpautop
, wptexturize
, convert_chars
and convert_smilies
.
I don’t recommend it, but it is possible to remove these filters to use javascript code in the post content:
add_action('init','custom_init');
function custom_init() {
remove_filter('the_content', 'wpautop');
remove_filter('the_content', 'wptexturize');
remove_filter('the_content', 'convert_chars');
remove_filter('the_content', 'convert_smilies');
}
Related Posts:
- Add Item to Custom TinyMCE Menu
- Strange gibberish JavaScript in Editor – site hacked?
- Close TinyMCE plugin window on click away
- Trouble adding JavaScript in visual editor (Sharpspring embed code)
- Custom wp.editor.initialize settings ignored
- Popup box when Clicking on Insert into post button in wordpress
- wordpress 4.4 upgrade visual editor bullets select for not selected elements
- disable tags on wordpress text editor
- How to stop javascript code being broken when going into visual editor
- How to use WP switchEditors.switchto(this) JS function in your own script?
- VisualComposer/WPBakery Page Editor: Is any JS event triggered after the Edition pop-in is shown?
- Dynamically write in editor with Javascript
- How can I generate a rainbow circle using HTML5 canvas?
- Which equals operator (== vs ===) should be used in JavaScript comparisons?
- are there dictionaries in javascript like python?
- Dynamically creating charts of each row in an HTML table with chart.js
- Client on Node.js: Uncaught ReferenceError: require is not defined
- jQuery .on(‘change’, function() {} not triggering for dynamically created inputs
- How to create a jQuery function (a new jQuery method or plugin)?
- Failed to load resource: the server responded with a status of 500 (Internal Server Error) in Bind function
- Scroll to an element with jQuery
- Cannot open local file – Chrome: Not allowed to load local resource
- How do you reverse a string in-place in JavaScript?
- How to get the browser to navigate to URL in JavaScript
- Uncaught TypeError: Cannot read property ‘length’ of undefined
- Python to JavaScript converter
- SyntaxError: Unexpected token o in JSON at position 1
- Fastest way to duplicate an array in JavaScript – slice vs. ‘for’ loop
- What is the difference between call and apply?
- AJAX response error: net::ERR_EMPTY_RESPONSE
- TypeError: Cannot Set property ‘onclick’ of null
- Efficient way to implement Priority Queue in Javascript?
- How do you format a Date/Time in TypeScript?
- JavaScript function in href vs. onclick
- How to scroll to an element?
- How would I call a javascript function in html?
- Mismatched anonymous define() module
- Function is not defined – Uncaught ReferenceError
- Change text on hover, then return to the previous text
- How do I include a JavaScript file in another JavaScript file?
- Textarea Auto height
- Angular 2 – Using ‘this’ inside setTimeout
- Download data URL file
- What does the construct x = x || y mean?
- Discord error cannot read property ‘isFocused’
- onClick not working React js
- What language is JavaScript written in?
- How to output numbers with leading zeros in JavaScript?
- How to instantiate a File object in JavaScript?
- How to change the buttons text using javascript
- How to sort in mongoose?
- “Uncaught TypeError: a.indexOf is not a function” error when opening new foundation project
- How do you serve a file for download with AngularJS or Javascript?
- How can I cache image files locally with PhoneGap / Cordova?
- how to display a div triggered by onclick event
- Detect a finger swipe through JavaScript on the iPhone and Android
- How to export JavaScript array info to csv (on client side)?
- Should I use encodeURI or encodeURIComponent for encoding URLs?
- JAX post error : Refused to set unsafe header “Connection”
- How to use onBlur event on Angular2?
- img onclick call to JavaScript function
- Bootstrap Collapse not Collapsing
- How to scroll to top of page with JavaScript/jQuery?
- Check if a JavaScript string is a URL
- How to use Head JS with all enqueued scripts?
- How to add code to just before closing body tag
- Switch to the library tab in the media uploader
- Customizer JS API: Defining control settings
- Customizer JS API: Adding Setting Dynamically Not Working
- Using React.js in WordPress
- Updata Metadata WP Rest API
- How to add JavaScript file using wp_enqueue_scripts?
- Custom block SelectControl works but equivalent ComboboxControl gives errors – where’s my mistake?
- Customizer JS API: Adding a “dropdown-pages” control
- wp.editor.initialize does nothing
- Enqueue Javascript After ALL Other Scripts (Including Async Scripts)
- Enqueue js script to footer
- Render blocking issue in google page insight
- Adding nonce or hashes to inline scripts
- Open MediaUpload from external component in Gutenberg
- WordPress Media Library: Custom tab content displayed in “Media Library” tab
- Manually mark imported photo as selected in media library
- Call post-id from URL hash not working?
- Easy popups for wordpress?
- Script to Automatically Advance to the Next Page of a Paginated Post
- How can I get user data into a javascript object?
- Why WordPress not using JSON_UNESCAPED_UNICODE by default?
- WordPress load-scripts.php not loading
- get_header() in backend – but keep JavaScript and CSS files
- Absolutely print script in footer
- How can I put this JavaScript into WordPress? [closed]
- Need help in fixing javascript in WordPress
- Uncaught TypeError: r is not a function
- How to show cities according to the state in Form using Javascript? [closed]
- Redirect to homepage if attmpting to leave intranet [closed]
- Twenty seventeen theme dropdown menu issue
- Unserialize WP_Options options programatically?
- Custom JS doesn’t work after 4.9.9 update [closed]
- Loading 2 Different Version of JS files [closed]
- Adding react app to an existing wordpress website