Functions.php if/else depending on Template Name
-
So after working for 2 days on this problem I still can’t seem to find a solution for my problem.
In the functions.php I include my CSS and JS files. Now I use multiple templates for the design work (because custom pages) and now I want to add the CSS and JS to only those templates.
Functions.php:
if (! is_admin()) { function load-files() { wp_register_style('defaultStyle', esc_url( get_stylesheet_directory_uri() ).'/default.css'); wp_enqueue_style('defaultStyle'); wp_register_script('defaultjs', esc_url( get_stylesheet_directory_uri() ).'/js/default.js', '', '', true); wp_enqueue_script('defaultjs'); } add_action('init', 'load-files'); }
This will include my normal CSS and JS. Now I need to get an if/else statement for the Template name. For example my about us page will be called aboutus-template.php and template name: About us now I want to include extra CSS files for the slideshow, google maps etc (just an example 😛 ). How can I do this without giving every page the about us css and js?
Thanks in advance!
- The topic ‘Functions.php if/else depending on Template Name’ is closed to new replies.