I pasted in some code, and WordPress made it disappear!

This entry was posted by on Wednesday, 2 April, 2014 at

Does this sound familiar?

I got some code from our catalog vendor and they told me that I could put a search box on my Web site. All I had to do was past in this code:

<script type="text/javascript" src="https://libraryname.biblionix.com/feeds/apollo_feeds.js">
<table apollo_feed="recent_added:days_back=10:max=5:horizontal:minimal=1"></table>

I did that, and saved my changes but then when I looked again all that was in the box was:

<table></table>

What happened?

The code in this example isn’t necessarily exactly what you were using but the problem is the same. Sometimes WordPress removes HTML code that you’ve pasted into your site. Why is that?

Simply put, WordPress has some built in security that removes code that it views as “non-standard” and/or potentially harmless. In the above example the bit about the “apollo_feed” is not standard HTML so it was removed. The whole <script> line was removed for security reasons as scripting is very powerful and it can be used for good, but it can also be used for evil. By default, WordPress defaults to a very cautious stance and that’s ultimately a good thing.

However, I’ve been working with a few libraries recently and there is a solution that I can implement from this end. So, if you’re encountering this problem, please send me the code you’re trying to use, what it’s supposed to do, and let me know where on your page you’d like it to appear. For security reasons we’ll still take a look at it to make sure it won’t cause any problems and as long as it doesn’t I’ll happily implement it for you.


Leave a Reply