1

I am trying to enqueue Bootstrap's CSS only on two pages.

Here's the code I have in my functions.php file:

function bootstrap_css() {
    if (is_page('who-we-are-2') ||  is_front_page()) {
    wp_enqueue_style('bootstrapstyle', '//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
    }
}
add_action('wp_enqueue_scripts', 'bootstrap_css');

From other StackExchange questions and Googling, that code should work. It works for the home page, but not on the "who-we-are-2" page. What's odd is is_page('who-we-are-2') doesn't work by itself. I have also tried is_page(32365) and is_page('32365'), 32365 being the page ID to no avail.

Any help would be greatly appreciated!

  • 1
    That should work. Is 'who-we-are-2' published? Have you tried deactivating all your plugins so your theme is the only thing enqueueing files? – WebElaine Apr 24 '17 at 17:49
  • The page was set to private published. Tried it normal published and no luck. I need a couple plugins for the page to work, but I disabled everything else. No dice. – Nick Taylor Apr 24 '17 at 18:44
1

UPDATE: It looks like it has something to do with the URL. For some reason I can view the page at /who-we-are-2 and it looks normal, minus the scripts/styles I am trying to enqueue. But the page should really be at /about/who-we-are-2 as About is the parent page. If I go to /about/who-we-are-2 it works perfectly. /about/who-we-are-2 is what is in the nav and the URL that users will see so we're all good. And obviously my enqueue wouldn't work on /who-we-are-2 since my if statement didn't call for that page. So ultimately, problem solved. But I'd love to know why I can view the page at /who-we-are-2 if anyone knows!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.