Wordpress functions.php conditional include another functions file
In my wordpress functions.php I have calls to include other function files. For example like so:
include(functions/articles.php);
include(functions/custompost.php);
Within those files I have all my functions that pertain to specific pages on the site.
What I want to do is this:
//Articles custom functions
function articles_fn() {
if ( is_page_template( 'page_templates/articles.php' ) ) {
include(functions/articles.php);
}
}
add_action( 'init', 'articles_fn');
//CustomPostType custom functions
function cpt_fn() {
if ( is_page_template( 'page_templates/custompost.php' ) ) {
include(functions/custompost.php);
}
}
add_action( 'init', 'cpt_fn');
...but this doesn't work. Any help is hugely appreciated.
Thank you