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!
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

Sofia Martinez
11,607 PointsTheme errors because of functions.php
Hi!
I'm in How to Build a WordPress Theme following all the process but with my own webpage and my own HTML code, etc. Everything is working just fine, except that I started noticing some errors in the Admin Panel. For example, when I want to update a page adding new content (or a blog post), it redirects to wp-admin/post.php but the page is blank, and my page/post is not updated (it happens with every page/post).
I changed the theme to the default (Twenty Twelve) and all worked perfectly fine, so I realize it was related with the theme I was creating, not WP. I started erasing files to find out which had the error. When I erased functions.php, the pages/posts updated fine, so it is this file.
So, I erased parts of the content, and finally all the content to find out where was the error, but even when I erased all the content, I couldn't still update the pages/posts. It only works when I erase completely the functions.php file.
Although it only works with all the file erased, I'll copy the content of the file:
<?php
// Load the Theme CSS
function theme_styles() {
wp_enqueue_style('normalize', get_template_directory_uri() . '/css/normalize.css');
wp_enqueue_style('grid', get_template_directory_uri() . '/css/grid.css');
wp_enqueue_style('googlefonts', 'http://fonts.googleapis.com/css?family=Amatic+SC');
wp_enqueue_style('main', get_template_directory_uri() . '/style.css');
wp_enqueue_style('fonts', get_template_directory_uri() . '/css/fonts/fonts.css');
}
// Load the Theme JS
function theme_js() {
wp_enqueue_script('theme_js', get_template_directory_uri() . 'js/theme.js', array('jquery'), '', true);
}
add_action('wp_enqueue_scripts', 'theme_js');
add_action('wp_enqueue_scripts', 'theme_styles');
// Enable custom menus
add_theme_support('menus');
?>
Can someone help me, please?
Thanks!
7 Answers

Kevin Korte
28,147 PointsDo you have any extra returns after your closing php tag? I always leave that final closing php tag off on the functions.php file so I do not have to worry about that. That could be your issue.
Is this a custom theme or a child theme?

Matt Campbell
9,767 PointsLeading / on js/theme.js is missing.

Sofia Martinez
11,607 PointsYou're right, thanks!
But still it isn't working...

Matt Campbell
9,767 PointsHave you gone through, deleting one row of enqueue at a time?
The error could be in one of those files.

Sofia Martinez
11,607 PointsYes, deleting one row at a time... the hole content of the file..., it just works again when I delete the file itself.

Sofia Martinez
11,607 PointsOMG... yes, I had two blank lines after the closing php tag that were causing the error. Thanks a lot!

Kevin Korte
28,147 PointsYou are welcome. That is why I leave the final closing PHP tag off.

Kevin Korte
28,147 PointsMy mistake