Trying to load conditional content thru the header, but only front page is being identified correctly. Archive, post and custom type templates aren't.
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?
is_page_template()
only checks if the page is using a custom page template, not if which template is being loaded. If you want to check for a singular listing you need to useis_singular( 'listing' );