I’ve tried creating a new post on my WordPress blog and I’ve pasted an external code from a site, which has a <script src="..."></script>
in order to work.
When I publish my post, the script
tag simply gets deleted.
Is this a default behavior in WordPress? Is there any way to avoid this? (preferably without doing any modifications to WordPress or using inline code).
No this is not default behaviour in wordpress. I have added
<script>
tags to the html view of a page or post no problem.Did you switch the view after you add the code ? If so, don’t. WordPress will delete all tags if you switch to view back from HTML.
Like Tim said, you probably posted the code into the Visual Editor (doesn’t accept any HTML tags, like scripts). You should to the HTML editor to implement your code, but if you want to have it on more than one page, you should open up the Appearance Editor and paste it into your theme where you need it (most likely in the header).
If you put the script code in html and then switch to the visual editor, it will delete the script. This is a commonly reported problem and is the default behavior of wp.
WordPress assigns Roles to Users, Users who are either Administrators or Editors can add javascript codes within posts. If the User’s role is Author or Contributor then they can not add javascript codes inside posts, even if these users try to add Javascript in HTML mode, wordpress automatically removes the tags.