Javascript inside post not working

Posted in: Newspaper
Post count: 88

Hi there. I am well on my way of converting my joomla site to WordPress with Newspaper. However I am stuck on a post with a custom javascript.

On joomla: http://goo.gl/pbSto0
On newspaper: http://goo.gl/QGaQsl

The script is showing up when I inspect source so I am unsure what is going wrong here. Any thoughts?

Post count: 22421

Hello,

I do not think the MCE post editor from wordpress handles javascript very well. You can try to use visual composer on posts and add a ‘Raw JS’ box and try your code with it. You can also disable the article inline ad temporarily or maybe set it to display after another paragraph.
If this is not what you mean, please provide more details to your problem so we can understand better.

Thank you!

Post count: 88

Unfortunately I did not find a way to enable the visual composer on only that post. As with the advertisement I do not like the idea of changing the entire website’s foundation for this single posts.

Maybe I should try to externalize the script in a .js file. Will that work? I have never done this but I imagine that removes the need for the visual composer, right?

Post count: 22421

Hi,
You could try that although i cannot say for sure if it will work, but you could also try to use the theme panel’s custom JS box: http://screencast.com/t/xHjh19PPA (this is how it looks in the current version 6.6)
This is the intended way of adding JS to our theme.
Thank you!

Post count: 88

Thanks for explaining that function.

I managed to resolve the siutation with the following steps

1) create a new file and copy paste javascript to pcinside-psu-tool.js
2) upload pcinside-psu-tool.js to server
3) add to post:
<script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script><script src="http://nl.pcinside.info/pcinside-psu-tool.js" type="text/javascript"></script>
4) add to button in text mode (not visual!) onclick="initCalc();"

I hope this helps anyone else facing a similar situation!

  • This reply was modified 10 years by Magistar.
Post count: 22421

Glad you got it solved and thank you for posting your solution!

Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic.