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 trialshareyourpeace
3,244 PointsWhen I add a new page, the browser turns blank. http://localhost/projectWordPressThemeDev/wp-admin/post.php
Q Chapter: the page.php file I am following the Course exactly and so far everything is exactly as it shows up in the course. Until now.
Add New Page > i enter a 'name' and some 'content' > publish. This is the url when I am doing the above. http://localhost/projectWordPressThemeDev2/wp-admin/post-new.php?post_type=page
After I click publish, the browser turns WHITE. Not a thing on the screen. This is the url: (when it is blank) http://localhost/projectWordPressThemeDev2/wp-admin/post.php
Here is what happens when Zac does it. add new > page your_url: http://localhost:8888/projectWordPressThemeDev2/wp-admin/post-new.php?post_type=page click > publish your_url: post.php?post=15&action=edit&message=6
Note:
I have to click the back arrow to get back to the dashboard.
The Pages DO get Created !!
Thanks.
9 Answers
shareyourpeace
3,244 PointsResolved. In this line of functions.php:
add_action('wp_enqueue_scripts', 'my_theme_js()');
I don't need the parentheses in the function callback:
add_action('wp_enqueue_scripts', 'my_theme_js');
Someone else provided this answer to me.
Zac Gordon
Treehouse Guest TeacherThis is what is commonly referred to in the WordPress world as the white screen of death.
This article gives a really thorough overview of possible troubleshooting strategies, however, in this case, I would say step one would be to open the wp-config.php file and change the following line:
define( 'WP_DEBUG', false);
to
define( 'WP_DEBUG', true);
This should hopefully at least get you an error message with some more information.
Luis Martins
5,436 PointsIf you're on a mac, you might also find useful to open the Console app and open PHP log file there. Usually i'll have it open all the time, any errors during development will be automatically displayed there. Blank screen, as Zac Gordon mentions is likely due to a 5xx server error, some typo on your code most likely.
shareyourpeace
3,244 PointsI have changed the code from 'false' to define( 'WP_DEBUG', true); Here are the warnings and errors that return in the browser. note: Zac uses wpt_theme_js() Mine is named my_theme_js()
http://localhost:8888/projectWordPressThemeDev2/wp-content/themes/my_portfolio/wp-admin
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'my_theme_js()' not found or invalid function name in /Applications/MAMP/htdocs/projectWordPressThemeDev2/wp-includes/plugin.php on line 505
You need to zoom in to read the error: http://imgur.com/ufKnMoe
Here it is zoomed in. http://imgur.com/4XpXxQY
Code from plugin.php line 505
do {
foreach ( (array) current($wp_filter[$tag]) as $the_ )
if ( !is_null($the_['function']) )
call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
http://localhost:8888/projectWordPressThemeDev2/wp-admin/
Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/projectWordPressThemeDev2/wp-content/themes/my_portfolio/functions.php:47) in /Applications/MAMP/htdocs/projectWordPressThemeDev2/wp-includes/pluggable.php on line 1173
code from pluggable.php from line 1163-1173
$status = apply_filters( 'wp_redirect_status', $status, $location );
if ( ! $location )
return false;
$location = wp_sanitize_redirect($location);
if ( !$is_IIS && php_sapi_name() != 'cgi-fcgi' )
status_header($status); // This causes problems on IIS and some FastCGI setups
header("Location: $location", true, $status);
return true;
}
endif;
Here is my function.php code
function my_theme_styles() {
wp_enqueue_style('foundation_css', get_template_directory_uri() . '/css/foundation.css');
//wp_enqueue_style('normalize_css', get_template_directory_uri() . '/css/normalize.css');
wp_enqueue_style('googlefont_css', 'http://fonts.googleapis.com/css?family=Asap:400,700,400italic,700italic');
wp_enqueue_style('main_css', get_template_directory_uri() . '/style.css');
}
add_action('wp_enqueue_scripts', 'my_theme_styles');
function my_theme_js() {
wp_enqueue_script('modernizr_js', get_template_directory_uri() . '/js/modernizr.js', '', '', false );
wp_enqueue_script('foundation_js', get_template_directory_uri() . '/js/foundation.js', array('jquery'), '', true );
wp_enqueue_script('main_js', get_template_directory_uri() . '/js/app.js', array('jquery', 'foundation_js'), '', true );
}
add_action('wp_enqueue_scripts', 'my_theme_js()');
Thanks for the help.
Zac Gordon
Treehouse Guest TeacherThank you so much for posting up all this helpful information! What was on line 46-48 on your functions.php file? In the last image you posted it notes an error on line 47 of functions.php. The functions.php code you posted up doesn't seem to have that many lines.
shareyourpeace
3,244 PointsThanks Zac, There is nothing there !
function my_theme_js() {
wp_enqueue_script('modernizr_js', get_template_directory_uri() . '/js/modernizr.js', '', '', false );
wp_enqueue_script('foundation_js', get_template_directory_uri() . '/js/foundation.js', array('jquery'), '', true );
wp_enqueue_script('main_js', get_template_directory_uri() . '/js/app.js', array('jquery', 'foundation_js'), '', true );
}
44 add_action('wp_enqueue_scripts', 'my_theme_js()');
45 ?>
46
47
shareyourpeace
3,244 PointsZac....
I just removed those 2 empty lines and it appears to be working !!
Weird that empty code lines after closing php tags bring about an error.
SO
I get the dashboard back.
The 505 error is still there as before.
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'my_theme_js()' not found or invalid function name in /Applications/MAMP/htdocs/projectWordPressThemeDev2/wp-includes/plugin.php on line 505
I looked here:style.css
I have the Theme Name: defined.
I did not change the URI or the other tags.
Does this matter ?
style.css
/*
Theme Name: my_portfolio theme
Author: shareyourpeace
Author URI: http://teamtreehouse.com/
Description: A post modern, simple, responsive portfolio theme designed in WordPress Theme Development course at Treehouse.
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: green, blue, white, light, one-column, two-columns, left-sidebar, flexible-width, fluid-layout, responsive-layout, custom-menu, featured-images
At Treehouse we believe that you should reach for your dreams.
You are welcome to use this theme privately or commercially you want to help accomplish those dreams!
*/
index.php
<?php get_header(); ?>
<section class="row">
<div class="small-12 columns text-center">
<div class="leader">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<p><?php the_content(); ?></p>
<?php endwhile; else : ?>
<p><?php _e( 'Sorry, no results found.', 'my_portfolio theme' ); ?></p>
<?php endif; ?>
</div>
</div>
</section>
<?php get_footer(); ?>
Thanks again.
Zac Gordon
Treehouse Guest TeacherAlright! Looks like you got it all resolved :)
Yes, empty blank spaces outside of the PHP block will result in errors.
And you're correct that the () cannot be there when you're referencing a function since it will actually call the function instead of reference it.
shareyourpeace
3,244 Points:)
I like the way you rephrase-explain this !! " you cannot add ( ) when referencing a function since it will actually call the function instead of referencing it".
Nijad Kifayeh
6,092 PointsSo weird.
In case anybody else is having this "white page of death" issue, the resolution for me was simply to delete any empty lines after the closing ?> in functions.php.
Can any of the mods explain why thee empty lines would cause this error?@