Title: Where to insert Javascript code into HTML body tags
Last modified: March 9, 2017

---

# Where to insert Javascript code into HTML body tags

 *  [lasmith](https://wordpress.org/support/users/lasmith/)
 * (@lasmith)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/where-to-insert-javascript-code-into-html-body-tags/)
 * I feel like this should be common knowledge, but I’ve hit a roadblock. I have
   one line of JS code that I’m using for geo-targeting images based on location.
   It works correctly when I place it in the header or footer of my theme (I am 
   using a child theme so I activate the parent theme, place it, and then activate
   my child theme again), but I can’t for the life of my figure out where to access
   the basic HTML file for my website. This JS script can only be placed in between
   the opening and closing body tags, nowhere else. Is there a way to access the
   HTML file of my website without having to download it via FTP and save it locally?
   There are a lot of permissions issues with doing that at my company and I’d rather
   do it within WordPress.org if possible.
 * Also, putting this line of code in the “text” editor of one of my pages does 
   not work, in case anyone was going to suggest that.
 * Thanks in advance!

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [graphicscove](https://wordpress.org/support/users/graphicscove/)
 * (@graphicscove)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/where-to-insert-javascript-code-into-html-body-tags/#post-8895342)
 * Hello,
 * Can you not find it under ‘Appearance’ -> ‘Editor’?
 * ~ Steven
 *  Thread Starter [lasmith](https://wordpress.org/support/users/lasmith/)
 * (@lasmith)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/where-to-insert-javascript-code-into-html-body-tags/#post-8895479)
 * [@graphicscove](https://wordpress.org/support/users/graphicscove/), nope. There
   is no HTML template in the right hand column that lists all the templates. Just
   a bunch of PHP templates and the CSS file.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/where-to-insert-javascript-code-into-html-body-tags/#post-8896037)
 * For the most part, any CMS like WordPress does not have any HTML files at all.
   All content is kept in a database and output through a system of templates. Most
   of those PHP files you see in the theme editor are templates that output HTML
   content. If you examine some of these files, you’ll see many of them are a combination
   of PHP code and HTML content.
 * While it varies by theme, the opening body tag of any given page is output from
   header.php and the closing body tag is output from footer.php. These files are
   part of virtually every page output. The other templates are used as needed depending
   on the nature of the requested page.
 * Thus, if you want your script to run on every page, footer.php is a good place
   for this. Just be sure you place it in <script> tags and you are outside of any
   PHP code when you insert it. If you want to restrict which sort of pages on which
   the script is included, you can use PHP conditional structures and template tags
   like is_single().

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Where to insert Javascript code into HTML body tags’ is closed to new
replies.

## Tags

 * [html](https://wordpress.org/support/topic-tag/html/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 3 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [9 years, 2 months ago](https://wordpress.org/support/topic/where-to-insert-javascript-code-into-html-body-tags/#post-8896037)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
