• 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 www.remarpro.com 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)
  • Hello,

    Can you not find it under ‘Appearance’ -> ‘Editor’?

    ~ Steven

    Thread Starter lasmith

    (@lasmith)

    @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

    (@bcworkz)

    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.