Jump to content

JavaScript Not Functioning In WordPress Posts


ajstancato

Recommended Posts

I am having a difficult time getting JavaScript to run in a Wordpress Post.

 

I work extensively in forms, and creating calulators of different sorts. I want each script to be local for only one single post, not global. I know I can include the path in the header.php file, but with all the scripts I want to include in the Wordpress websites, I don’t want to convolute the header.php with lots of local file paths which are going to be one and done.

 

I know Wordpress changes the html syntax when switching from text to visual, that is not my problem. The scripts I have written works in every editor I use, and with all the most popular browsers, but not when posted in Wordpress from the file.js path or when inserted with <script> tags. I can get very simple scripts with an alert() function, or document.write() function to work, but when I attempt form manipulation, no luck. When troubleshooting from a console, none of the variables or functions are acknowledged.

 

All the websites I deal with are Wordpress. I'm frustrated because I want to really grow and expand my JavaScript skills, but I constantly hit dead ends with Wordpress and no one can offer guidance.

 

I've been told to write everything in PHP. I am new to programming and want to learn JQuery and javaScript well before taking on any other language!

 

Please Help!

Link to comment
Share on other sites

If you're trying to figure out why it's not working, I would start by looking in the database to see what is actually being saved for the post. Maybe that code is being stripped out before even getting to the database. If it looks fine in the database then I would check the rendered page to make sure I see the code there and that it was printed correctly, then check the console for error messages and things that like.Note that there are probably plugins out there to change the behavior or features of adding posts. If you find a solution on one site it might not work on others.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...