最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

functions - How to reference different css (bootstrap) stylesheets for the header and body of a page?

programmeradmin1浏览0评论

Thanks in advance for the help, and apologies if I'm being dumb, I'm rather new. I have tried various different answers on this site, but they did not work, as they were meant for different pages. I am trying to have the header and main body have a different bootstrap version.

For the website, I created a navbar (in a file called header-topnav.php) with bootstrap 4.1.3 (.1.3/css/bootstrap.min.css) and the body / rest of the website was created with bootstrap 3.3.7, and when I enqueue both in functions.php, it seems that there are major conflicts with the styling of the body but the navbar is fine.

If I only link the bootstrap 4 to the header-topnav.php file, it still conflicts with the body. Trying the following after registering bootstrap4 in functions.php did not work:

<?  function topnav_enqueue_style() {

  wp_enqueue_style( 'bootstrap4-css');
}
add_action( 'wp_enqueue_scripts', 'topnav_enqueue_style' ); ?>

Trying a conditional in functions.php didn't work (as expected) because my custom header is not a page, persay. Just a header.

    if( is_page( 'header-topnav' ) ) {   // Only add this style onto the Blog page.
        wp_enqueue_style( 'bootstrap4-css' );
    }

How can I have bootstrap 4 applied to the header and ONLY the header? I would like this to be applied to the header of all pages, but only have the header utilize bootstrap 4 as of now. Is there some if statement I could use in the functions.php to do this? Thank you so much.

发布评论

评论列表(0)

  1. 暂无评论