Jump to content
ajstancato

JavaScript Not Functioning In WordPress Posts

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!

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...