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 WordPress Theme Development Working with CSS and JS in WordPress Themes How to Link to JS from functions.php File

Alexander van Ravestyn
Alexander van Ravestyn
3,403 Points

Fatal error: Call to undefined function add_actions()

Whenever I try to load my homepage, I get a fatal error telling me that I'm calling an undefined function add_actions() in my functions.php file! I have installed wordpress locally on my computer with DesktopServer like it was described to me in the "How to Install WordPress on Your Computer" course. Could that have anything to do with it?

The full error message:

Fatal error: Call to undefined function add_actions() in /Users/Alexander/Documents/Websites/unifac.dev/wp-content/themes/unifac/functions.php on line 3

Screenshot of the error message: Imgur

The code in functions.php:

<?php
    function wpu_theme_styles() {
        wp_enqueue_style('bootstrap_min_css', get_template_directory_uri().'/css/bootstrap.min.css');
        wp_enqueue_style('bootstrap_theme_min_css', get_template_directory_uri().'/css/bootstrap-theme.min.css');
        wp_enqueue_style('google_fonts', 'https://fonts.googleapis.com/css?family=Montserrat|Open+Sans|Cormorant+Garamond:700italic');
        wp_enqueue_style('main_css', get_template_directory_uri().'/style.css');
    }
    add_actions('wp_enqueue_scripts', 'wpu_theme_styles');

    function wpu_theme_js() {
        wp_enqueue_script('bootstrap_min_js', get_template_directory_uri().'js/bootstrap.min.js', array('jquery'), '', true);
    }

    add_actions('wp_enqueue_scripts', 'wpu_theme_js');
?>

Thanks in advance for helping!

2 Answers

Alexander van Ravestyn
Alexander van Ravestyn
3,403 Points

Never mind! It was supposed to be add_action() instead of add_actions()! I won't forget that again ;-)

Hi Alexander,

I hope you don't mind I switched your comment to a Answer so other users can spot the error more easily :)

Craig