• Resolved bongkph

    (@bongkph)


    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)
  • 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.

    <?php if( is_single() ) get_template_part( 'ads' );?>

    Thread Starter bongkph

    (@bongkph)

    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.