Hi there, I've been trying to link a custom stylesheet for a custom page template, but don't seem to be able to get it to work for some reason. I've tried registering the stylesheet in functions.php, then tried to enqueue it. Here is what I did: function staff_style() { if ( is_page_template('page-templates/staff.php') ) { wp_enqueue_style( 'staff-custom-style', get_stylesheet_directory_uri() . '/CustomCSS/staff.css'); } } add_action('wp_enqueue_scripts', 'staff-style'); I have also created a custom header (header-myheader.php) to call the custom stylesheet. I then have inserted <?php get_header('myheader'); ?> in my template to call the header. I believe I must be doing something incorrectly, and have tried a lot of different tutorials, but I don't seem to be able to get it working. Is there any advice you could offer as to why I may be having an issue? Thank you.
Hi, Kindly put your custom CSS by following the steps below also I have attached an image for your reference: Please paste the CSS code given below in Custom CSS section (Appearance -> Theme Options -> Styling Options -> Custom CSS) of your dashboard. Regards, Sameer
Hi there If I put the my custom CSS into the Custom CSS section in the theme options, it is going to affect all pages e.g... #menu {color: red;} - (as a simple example) .....isn't going to just affect my custom page template. I know I can add the page-id in front of my CSS rules to target a specific page, but as there's quite a lot, I want to keep the CSS in its own stylesheet. I've already created the custom stylesheet, custom header, and the custom page template. The problem I'm having is linking the custom stylesheet in my custom header to my new template. Thanks.
Hi, I got your concern but the way that I mentioned in previously is the best way to apply custom CSS. If you try to linkup using source code then it can effect CSS of theme template. Regards, Sameer
Okay, thanks. As you're the expert, I'm sure that your recommended way must be the better idea then. Thanks.