Conditionally apply css for a specific template part

I am trying to add bootstrap.css conditionally via functions.php. I need to apply the bootstrap.css all over the website except about-us template. So in my functions.php

<?php
function lorem_ipsum(){
wp_register_style( ‘bootstrap’, ‘//maxcdn……..css’ );

if( !is_page_template(‘about-us.php’) ) {
wp_enqueue_style(‘bootstrap’);
}
}

Its working nice but the problem is: **header.php** also missing the styles from bootstrap but I don’t want that. I have tried to add other condition with existing condition, so I can apply bootstrap for the header.php and exclude bootstrap from about-us template.
I also checked the wordpress documentations but can’t figure it out. I believe, obviously there is a way, I just couldn’t figure it out. Have you any suggestion? -Thank you.

Read more here:: Conditionally apply css for a specific template part

Leave a Reply

Your email address will not be published. Required fields are marked *