Title: &quot;is_single&quot; include a templatepath
Last modified: August 20, 2016

---

# "is_single" include a templatepath

 *  Resolved [bongkph](https://wordpress.org/support/users/bongkph/)
 * (@bongkph)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/is_single-include-a-templatepath/)
 * Hi, I am working on a theme that has no single.php but rather a loop.php. I wanted
   to add a floating ad so to do that I use the code
    <?php include(TEMPLATEPATH.‘/
   ads.php’) ; ?>
 * But this code shows up even on homepage, so I wanted to show it only in “is_single.”
   I am not a PHP guy so please help me with this.
 * Thanks a lot.

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

 *  [Chip Bennett](https://wordpress.org/support/users/chipbennett/)
 * (@chipbennett)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/is_single-include-a-templatepath/#post-2541068)
 * Use the `is_single()` conditional. Also, use `get_template_part()` instead of`
   include()`. e.g.:
 *     ```
       if ( is_single() ) {
           // include ads.php
           get_template_part( 'ads' );
       }
       ```
   
 * Note also: `TEMPLATEPATH` is deprecated. You should be using `get_template_directory()`
   in its place, if/when you need to return the template path.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/is_single-include-a-templatepath/#post-2541071)
 * `<?php if( is_single() ) get_template_part( 'ads' );?>`
 *  Thread Starter [bongkph](https://wordpress.org/support/users/bongkph/)
 * (@bongkph)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/is_single-include-a-templatepath/#post-2541198)
 * Thanks so much chip & esmi, it both worked.

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

The topic ‘"is_single" include a templatepath’ is closed to new replies.

## Tags

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

 * 3 replies
 * 3 participants
 * Last reply from: [bongkph](https://wordpress.org/support/users/bongkph/)
 * Last activity: [14 years, 3 months ago](https://wordpress.org/support/topic/is_single-include-a-templatepath/#post-2541198)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
