I am used to of adding javascript/jquery code in posts via visual editor but it seems I never used && operator cause wordpress is altering && operator in &. Here is a link where I am using &&. http://demo.techstriders.com/corey/canyon/calculator/ I am wondering what is correct way of using javascript in wordpress visual editor.

1 Answer 1


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

        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:

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');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.