Title: Loading a script into post pages only
Last modified: August 19, 2016

---

# Loading a script into post pages only

 *  [Mr_Scientist](https://wordpress.org/support/users/mr_scientist/)
 * (@mr_scientist)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/loading-a-script-into-post-pages-only/)
 * I’m trying to include a script called Ketchup into post pages only and have written
   the following code in the functions php. I cannot work out why this if statement
   isn’t working. When the if statement is taken out and only the ‘enqueue’ part
   left in it loads, but into all pages.
 *     ```
       function call_ketchup() {
       	if (is_single()) {
       		wp_enqueue_script('ketchup', get_bloginfo('template_url') ."/scripts/jquery.ketchup.all.min.js", array('jquery'), '1.0');
       }
       add_action('init', 'call_ketchup');
       ```
   

Viewing 1 replies (of 1 total)

 *  [SSchat](https://wordpress.org/support/users/sschat/)
 * (@sschat)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/loading-a-script-into-post-pages-only/#post-1952346)
 *     ```
       function call_ketchup() {
       	if (is_single()) {
       		wp_enqueue_script('ketchup', get_bloginfo('template_url') ."/scripts/jquery.ketchup.all.min.js", array('jquery'), '1.0');
       }
       add_action('init', 'call_ketchup');
       ```
   
 * is missing the “}”?
 * maybe the action “init” is to early.
    try another action like “wp_head”…

Viewing 1 replies (of 1 total)

The topic ‘Loading a script into post pages only’ is closed to new replies.

## Tags

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

 * 1 reply
 * 2 participants
 * Last reply from: [SSchat](https://wordpress.org/support/users/sschat/)
 * Last activity: [14 years, 5 months ago](https://wordpress.org/support/topic/loading-a-script-into-post-pages-only/#post-1952346)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
