I'm using a 'specialized' page template called 'page-courses.php', following the codex: http://codex.wordpress.org/Page_Templates#Specialized_Page_Template
In my child theme's functions.php I want to add a php include only when using the page template.
I've used get_page_template() as a way of identifying the page template
if(strtolower(basename(get_page_template()))=='page-courses.php'){
include_once('functions_courses.php');
}
However, get_page_template() doesn't return anything at that point in the execution. If I run it after the loop...
function is_courses_page(){
if(strtolower(basename(get_page_template()))=='page-courses.php'){
include_once('functions_courses.php');
}
}
add_action('loop_end', 'is_courses_page');
... then 'page-courses.php' is returned, but too late for including my functions_courses.php file which includes enqueues. I'm not sure which action reference to use
I'm quite new to all this, so maybe I'm going about it in completely the wrong way, so any guidance would be much appreciated.
is_page('courses')
in your conditional.