I think your problem is how your function is constructed and not your condition as such.
You should not be wrapping your function and your action in a condition like this. Page templates are selected really late in the query by the main query, and I probably think that this is way to late for your action to execute. By the time the condition hits true, the wp_enqueue_scripts
hook already executed and cannot be rerun
If this is a single page, and that single page is for a custom post type called listing
, you should be using is_singular( 'listing' )
instead of is_page_template()
The correct way would be to wrap your scripts and styles inside your function inside your condition
You can try the following
add_action( 'wp_enqueue_scripts', 'your_function_name' );
function your_function_name() {
if( is_singular( 'listing' ) {
// add your scripts and styles
}
}