Title: JavaScript snippet in footer specific page
Last modified: August 31, 2016

---

# JavaScript snippet in footer specific page

 *  Resolved [ctuxboy](https://wordpress.org/support/users/ctuxboy/)
 * (@ctuxboy)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/javascript-in-footer-2/)
 * Hello,
 * I trying adding Javascript in the footer.
 * I’m adding this code in my functions.php:
 *     ```
       function locatie_winkel($pid){
          if (is_single()) {
              global $post;
              if($post->ID=="624"){ // only for post Id = 624
                   echo "<script>alert('hello world');</script>";
              }
          }
       }
       add_action( 'wp_footer', 'locatie_winkel' );
       ```
   
 * And this is the id of the page:
    ../wp-admin/post.php?post=624&action=edit
 * But when i look in the frontend to this page, then i don’t see the script in 
   the source code.
 * What doing wrong??
 * Regards,
    Christophe

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

 *  [Topher](https://wordpress.org/support/users/topher1kenobe/)
 * (@topher1kenobe)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/javascript-in-footer-2/#post-7158477)
 * Hi Christophe, I tried your code exactly as it is, and it worked for me. Check
   for caching to make sure you’re getting the freshest version of your page.
 *  Thread Starter [ctuxboy](https://wordpress.org/support/users/ctuxboy/)
 * (@ctuxboy)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/javascript-in-footer-2/#post-7158481)
 * Hi Topher,
 * Thanks for your answer, but i have no caching plugin :-/
    You mean that the code
   is correct.
 * Christophe
 *  [Topher](https://wordpress.org/support/users/topher1kenobe/)
 * (@topher1kenobe)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/javascript-in-footer-2/#post-7158483)
 * Yep, the code is correct. Can I see the url for post number 624?
 *  Thread Starter [ctuxboy](https://wordpress.org/support/users/ctuxboy/)
 * (@ctuxboy)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/javascript-in-footer-2/#post-7158492)
 * Hi Topher,
 * I find it
 * The id 624 is correct.
 * I remove this line:
 * `if (is_single()) {`
 * and of course the curly bracket at the end.
 * Now it works 🙂
 * Thank you for testing the code.
 * Regards,
    Christophe
 *  [Topher](https://wordpress.org/support/users/topher1kenobe/)
 * (@topher1kenobe)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/javascript-in-footer-2/#post-7158533)
 * That makes lots of sense, the docs for is_single say:
 * > Works for any post type, except attachments and pages
 * If you were looking at a page you should use is_page()
 *  Thread Starter [ctuxboy](https://wordpress.org/support/users/ctuxboy/)
 * (@ctuxboy)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/javascript-in-footer-2/#post-7158545)
 * Topher,
 * Thanks for the useful info.
    Indeed, now it works well.
 * Good to know 🙂
 * Regards,
    Christophe

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

The topic ‘JavaScript snippet in footer specific page’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 2 participants
 * Last reply from: [ctuxboy](https://wordpress.org/support/users/ctuxboy/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/javascript-in-footer-2/#post-7158545)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
