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

White Screen When Uploading Custom Theme

I copied the code to a T (and made sure all of my file names are correct) but I cannot get my custom code to work! It just shows a blank screen - no words, nothing. Any thoughts as to what the issue may be?

11 Answers

Have you activated your theme from the backend ? -> under "appearance" -> "themes" ? It should show up if wordpress recognises your theme.

Yup. The back end lets me select my custom theme, and that's when my website goes blank. If I active twenty twelve/thirteen/etc, it works fine.

Like I said, I've used the same code as the videos, and it's still not working. Would it be helpful if I uploaded the code?

The most important files are index.php and style.css - check those thoroughly. If something is wrong there, wordpress won't be able to display your theme correctly.

This is my code for index.php, function.php, and the style.css:

index.php: """ <?php // Silence is golden. get_header(); get_footer(); ?> """

function.php: """ <?php function theme_styles(){

    wp_enqueue_style('main', get_template_directory_uri().'/style.css');
}
add_action('wp_enqueue_scripts' 'theme_styles');

?> """

style.css: """ /* Theme Name: My Twenty Twelve Child Author: Angelina Marie Template: Twenty Twelve Child License: GNU General Public License v2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html */ @import url("../twentytwelve/style.css"); """

Thanks for taking a look!

Kevin Korte
Kevin Korte
28,148 Points

When this happens, the first file I always check is the functions.php file. 99% of the time I find my problem there. This likely means you have a PHP error.

Looking at yours, I see you missed a comma in your add_action hook.

It should be

add_action( 'wp_enqueue_scripts', 'theme_styles' );

I just removed the comma from my local test WP site here, and it returned a blank white page. Try that and see if it doesn't fix your issue.

Also, just FYI. You don't have to put a closing PHP tag if the file ends in PHP. And since the functions.php should only have PHP, I never put a closing PHP tag on that file. It helps eliminates the possibility of having a whitespace error at the end of the file.

Here is the docs on it http://php.net/manual/en/language.basic-syntax.instruction-separation.php

Here is the copy and pasted bit out of that page

The closing tag of a PHP block at the end of a file is optional, and in some cases omitting it is helpful when using include or require, so unwanted whitespace will not occur at the end of files, and you will still be able to add headers to the response later. It is also handy if you use output buffering, and would not like to see added unwanted whitespace at the end of the parts generated by the included files.

Thank you! I'll make sure to check my syntax from now on. However, my page is still blank!

www.angelina-marie.com

Kevin Korte
Kevin Korte
28,148 Points

By chance on your index page, you don't have your get_header() and get_footer() calls on the same line as the //Silence is golden do you?

No, they are on different lines.

Kevin Korte
Kevin Korte
28,148 Points

Do you have anything in your header and footer files?

What does that code look like?

This is my header:

""" <!DOCTYPE.html> <html> <head>
<title> <?php wp_title("|", true, "right"); bloginfo('name'); ?> </title> <?php wp_head(); ?> </head <body> <p>This is the header.</p> """

and my footer:

""" <p>This is the footer.</p> <?php wp_footer();?> </body> </html> """

Sorry for my late answer - i haven't had enough time lately.

In your header.php the doctype declaration should be <!DOCTYPE html>. There is a "." in between. But that's just a minor error and should not result in a blank page.

The code on your index.php, header.php and footer.php is fine. But make sure that you have a line brake after your comment //Silence is golden. If it's on the same line as get_header(); and get_footer(); it will comment out those functions and you'll have nothing to see on index.php.

I checked you're functions.php file and when testing it i got this PHP parsing error:

"Parse error: syntax error, unexpected ''theme_styles'' (T_CONSTANT_ENCAPSED_STRING) in functions.php on line 5"

This is due to a missing "," as Kevin noted before. When adding the missing comma it works fine.

Have you tried your theme locally using MAMP (on a mac) or XAMPP (on windows) ? It could be some PHP setting in the PHP configuration on your hosted server that causes some error.