Title: Help with adding a javascript to the page template?
Last modified: August 27, 2024

---

# Help with adding a javascript to the page template?

 *  [xprt007](https://wordpress.org/support/users/xprt007/)
 * (@xprt007)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/help-with-adding-a-javascript-to-the-template/)
 * Hi there
 * I would like to import some daily updated content from a certain site into WordPress-
   based page content. They provide 2 scripts, one javascript, the other php-based.
   I used the latter for years, but after changing hosts, the current shared webhost
   has some php function limitations which forced me to abandon it. The other day
   I remembered the javascript option, but there is an unexpected problem with it.
   Whereas on a non-Wordpress page all the content is printed, the script in WordPress
   content **leaves out some crucial portion, below the table**.
 * I wrote the site offering the script and they suggested it works on their WordPress-
   based and think some local scripts might be interfering. I did deactivate ALL
   plugins except the **SOGO Add Script Header Footer** with which I add some javascript
   component to the header, whereas the other portion is in the page content. It
   still had the same issue, although looking at the page source shows the code 
   for the missing content is there. The javascript I place in the header using 
   the WordPress plugin on the sample complete page code they provide is in the 
   héader.
 * Could it be adding the code directly to the page template, apparently as the 
   script’s instructions say, instead of using the **SOGO Add Script Header Footer**
   plugin would help and **IF SO, exactly how do I go about this, not being a coder
   and not wanting to the break the site?** I use the Spacious theme. Would that
   page template addition be gone in case I update the theme or WordPress & if so,
   exactly how can this be avoided?
   Instructions:_Include following line into your
   page`s template – …_“The javascript for importing here”
 * Thank you in advance.
    -  This topic was modified 1 year, 9 months ago by [xprt007](https://wordpress.org/support/users/xprt007/).
    -  This topic was modified 1 year, 9 months ago by [xprt007](https://wordpress.org/support/users/xprt007/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fhelp-with-adding-a-javascript-to-the-template%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Moderator [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/help-with-adding-a-javascript-to-the-template/#post-17978873)
 * Can you please show which JavaScript is involved and which instructions you are
   referring to? Then it would also be interesting to see what you have inserted
   where. You are welcome to show a screenshot: [https://wordpress.org/support/forum-user-guide/block-editor/#adding-screenshots](https://wordpress.org/support/forum-user-guide/block-editor/#adding-screenshots)
 *  Thread Starter [xprt007](https://wordpress.org/support/users/xprt007/)
 * (@xprt007)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/help-with-adding-a-javascript-to-the-template/#post-17980074)
 * Thank you for the response. I have done this differently. If you go to the link“
   The page I need help with”, I have added at the very bottom, below the table 
   a link “_**Complete Code + All content as it should appear in WP-page”**_ (opens
   new page) to a page I made using the **complete code provided** of a sample page
   and as you see **outside WordPress **provides the content I would like to appear
   on that WordPress page. **If you look at its page source code, **the javascript
   in the header is the one meant here in the script use instructions => “**Include
   following line into your page`s template”:**
 * “If you cannot use server-side scripts for the data import operations, you can
   use our JavaScript object elements to get the information on the current giveaway.
 * Other than that JS in the header, **I added the rest of that code between the
   body tags in the WordPress page**, where as you see, it only prints content up
   to the table and nothing below, i.e. _the download links + terms_.
 * The question remains the same above. I just want all the content to appear or
   it makes no sense.
 * Thank you in advance
    -  This reply was modified 1 year, 9 months ago by [xprt007](https://wordpress.org/support/users/xprt007/).
    -  This reply was modified 1 year, 9 months ago by [xprt007](https://wordpress.org/support/users/xprt007/).
 *  Moderator [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/help-with-adding-a-javascript-to-the-template/#post-17983925)
 * Unfortunately, I can’t find a demo page on the link mentioned. It’s hard to help
   you with that much description.
 * However, I see a JavaScript error in your page, which will probably stop any 
   further execution. The reason is in a line from
 *     ```wp-block-code
       if(gaotdObj.active){
       ```
   
 * can be seen. There, an HTML code within a JavaScript variable is output on several
   lines, which is not possible. It should – as is already the case in other places
   on your page – be on one line.
 * Fix this problem and your scripts should run normally. I would recommend checking
   the JavaScript console of your browser after the correction to see if it still
   displays errors: [https://developer.wordpress.org/advanced-administration/debug/debug-javascript/](https://developer.wordpress.org/advanced-administration/debug/debug-javascript/)
 *  Thread Starter [xprt007](https://wordpress.org/support/users/xprt007/)
 * (@xprt007)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/help-with-adding-a-javascript-to-the-template/#post-17984705)
 * _Unfortunately, I can’t find a demo page on the link mentioned. It’s hard to 
   help you with that much description._
 * I’m quite weary of adding any links here because there was what I think an overreaction
   from the forum moderation when about 3 years ago, I included some links in a 
   support request showing where some problems where being caused. I think this 
   post is the first in all these years which is not put on hold for moderation,
   sometimes for way too long, even if 99% of my forum posts before and after that
   included no links.
 * As I explain, at “The page I need help with”, at the bottom of the page is a 
   link “Complete Code+ All content as it should appear in WP-page”. This link shows
   an external page outside WordPress, which has the complete code with only that
   code of a sample page generated.
 * **I have now added below that => the link to the site providing the javascript
   code and their short explanation of how to use the code.** You will note their“
   See it in action” sample page looks exactly like the “Complete Code+ All content
   as it should appear in WP-page”, though this is OUTSIDE WordPress as well. May
   be if you “Download template`s sample” on that site you could check it out and
   see what is preventing it from working within WordPress.
 * As said, I’m not a coder and so would not know how to correct the javascript 
   and so would appreciate any help. Just a reminder: deactivating ALL plugins except
   the one allowing placing the header javascript made no difference.
 * Regards

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

The topic ‘Help with adding a javascript to the page template?’ is closed to new
replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [xprt007](https://wordpress.org/support/users/xprt007/)
 * Last activity: [1 year, 9 months ago](https://wordpress.org/support/topic/help-with-adding-a-javascript-to-the-template/#post-17984705)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
