Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress From Bootstrap to WordPress Setup a Bootstrap Theme Add Bootstrap CSS via the functions.php File

Ian Mackenzie
Ian Mackenzie
11,062 Points

wp_enqueue_style to functions.php I get this

I get this message, what does it mean?

Notice: Use of undefined constant theme_styles - assumed 'theme_styles' in /wp-content/themes/bootstrap-wp/functions.php

This is my functions.php file:

<?php
function theme_styles() {
    wp_enqueue_style( 'bootstrap_css', get_template_directory_uri() . '/css/bootstrap.min.css' );
}
add_action('wp_enqueue_scripts', theme_styles);
?>

1 Answer

Sue Dough
Sue Dough
35,800 Points

Try putting single quotes around theme_styles and see if that works.

<?php
function theme_styles() {
    wp_enqueue_style( 'bootstrap_css', get_template_directory_uri() . '/css/bootstrap.min.css' );
}
add_action('wp_enqueue_scripts',  'theme_styles');
?>
Ian Mackenzie
Ian Mackenzie
11,062 Points

Thanks for your help. I'm out now but I'll try that later today.