How to add inline JavaScript to a wordpress tempate file

How to add inline JavaScript to a WordPress template file?” Plus add it to every post on my page? for instance, <script type="text/javascript">alert('hello world');</script> would be…

Related posts

Leave a Reply

1 comment

  1. Adding it to a template is easy; just stick it within a tag in any part of the template you want to add it to. For instance:

    <script>alert('Hello world!');</script>
    

    as an incredibly basic (and kinda messy and improper) way to demonstrate it. Any template file is just a PHP file, or in other words an HTML file with some extra PHP code thrown in.

    Also, to add something to a post, you’ll want to add it to the appropriate part of your WordPress template. For instance, in the default Twentytwelve theme, that’d be the content.php file–that contains the code for a single article, and adding something to that will add it to every instance of an article on the page.