0

Can anyone tell me how to enable Bootstrap on a site using the twentyeleven theme? I followed the instructions for activating Bootstrap with the twentyfourteen theme without success.

This is the code I uploaded in the functions.php in my twentyeleven-child folder:

<?php add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); function theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); } function my_scripts_enqueue() { wp_register_script( 'bootstrap-js', '://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js', array('jquery'), NULL, true ); wp_register_style( 'bootstrap-css', '://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css', false, NULL, 'all' ); wp_enqueue_script( 'bootstrap-js' ); wp_enqueue_style( 'bootstrap-css' ); } add_action( 'wp_enqueue_scripts', 'my_scripts_enqueue' ); ?> 

Do I have to manually activate it somehow after I upload the file?

EDIT:

I just checked my source code and discovered that I have "enabled" Bootstrap...

http://mysite://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css' type='text/css' media='all' />

The obvious problem is that the style sheet links point to my site, rather than maxcdn. Does anyone know how I can fix that?

I guess the obvious answer is to just find the files that hold the style sheet and JS links and insert the Bootstrap links manually?

2 Answers 2

1

The way of using script and style enqueuing is correct, I think the error here lies in the column before the double "//" prefix of maxcdn URL. Try to remove the column in both urls.

2
  • Thanks, I tried that, but it didn't fix the problem; it changed the URL's a bit, but the link to the Bootstrap files still include my domain name. Commented May 29, 2016 at 5:07
  • Didn't find any reference in wordpress codex, but maybe your browser/your configuration cannot handle the protocol-less urls (that is: //something.com instead of http[s]://something.com). I'd try to change the maxcdn url to standard https:// urls) Commented May 29, 2016 at 5:13
1

write the following in your code

<?php add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); function theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); } function my_scripts_enqueue() { wp_register_script( 'bootstrap-js', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js', array('jquery'), NULL, true ); wp_register_style( 'bootstrap-css', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css', false, NULL, 'all' ); wp_enqueue_script( 'bootstrap-js' ); wp_enqueue_style( 'bootstrap-css' ); } add_action( 'wp_enqueue_scripts', 'my_scripts_enqueue' ); ?> 

it will download your file

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.