is_page_template showing partial results

by MauF   Last Updated July 11, 2019 22:08 PM

Trying to load conditional content thru the header, but only front page is being identified correctly. Archive, post and custom type templates aren't.

enter image description here

Using Query Monitor to identify correct template and used that template name as argument, with and without child theme folder declaration, but every other template falls into the else conditional.

    <?php
/* Conditional AD script loading */

/* Front page */
if ( is_home() || is_front_page() ) {
    echo "Front page";
} elseif ( is_page_template(  'single-listing.php' ) ) {
    echo "Listing page template";
} elseif ( is_archive() ) {
    echo "Archive page template";
} elseif ( is_page_template( $template  ='single.php' ) ) {
    echo "Post template";
} else {
    echo "wrong template";
}

?>

PHP elseif is in header of child theme, template files are within child theme folder too. What am I missing?



Related Questions


Updated August 10, 2017 00:08 AM

Updated April 05, 2018 14:08 PM

Updated December 08, 2017 09:08 AM

Updated July 09, 2016 08:03 AM

Updated February 01, 2017 14:03 PM