WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Functions.php on Twentyten child theme causes blank pages (MU setup) (24 posts)

  1. wpcubus
    Member
    Posted 3 years ago #

    I have a weird issue with a custom made child theme for the default Twentyten theme (shipped with WordPress 3.0).

    After I activate the child theme (without any warning) every "Publish" or "Save changes" action results in a blank page. At some times even logging in to the admin section results in a blank page too.

    This problem was solved after deleting the functions.php file I had included in my theme. First I thought I messed up something there, but even an empty functions.php file causes the same issue.

    I'm a bit clueless, because I used the same child theme on another wordpress setup without any problems. Only thing different in this case is that we setup wordpress as an MU platform.

    Anyone any thoughts on what could cause this issue?

    Problem is similar to: http://wordpress.org/support/topic/413853 but my server settings (PHP version, ...) shouldn't be any issue.

  2. Matt Northam
    Member
    Posted 3 years ago #

    Did you ever manage to resolve this? I'm getting the exact same issue, but on a normal WP install. White screen of death whenever I activate a child theme with 'functions.php' in it, or place that file into an active theme.

  3. acrane
    Member
    Posted 3 years ago #

    I've resolved this by making sure no extra returns or lines are on the page after the last closing php tag "?>" in your functions.php file

    It just doesn't like extra spaces/lines after it closes a function.

    Hope that resolves your issue!

  4. BionicSquid
    Member
    Posted 3 years ago #

    I've got a similar issue: I get syntax errors indicating functions have already been called. Any resolution to this? I have no extra returns or lines, just one or two functions. It's all very simple but doesn't work.

  5. acrane
    Member
    Posted 3 years ago #

    @bionicSquid , link to the problem? Want to paste your functions?

  6. New Nine Media
    Member
    Posted 3 years ago #

    Sometimes, the typical fix (delete whitespace, close last PHP tag, etc) doesn't work (I've found). There's just something with the functions.php file.

    The Fix (sometimes): Open functions.php, copy everything, paste it to a new text document. Delete functions.php. Save the text document as functions.php.

    This has worked for us in the past.

  7. outolumo
    Member
    Posted 3 years ago #

    The problem may actually be that there are blank lines in the file and redirection won't handle it well.
    http://www.cyberciti.biz/faq/php-redirect/ explains how they may interfere with any redirection code.

    Note that blank lines that are between <?php and ?> tags don't make a difference: php preprocessor cleans them out before the http protocol level redirection takes place.

    This is also why New Nine Media's fix works sometimes: the editor may trim empty lines from the end of the file. It won't help with lines that are in the middle of the file though.

  8. Flocktome
    Member
    Posted 3 years ago #

    Yup,
    Simply open up functions in text editer, and delete any whitespace at the end. If you try this in anything but a pure text editor you may still get the same problem.

  9. rdf
    Member
    Posted 3 years ago #

    Although I have changed headers a few times I now am getting the following error codes:
    Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 12288 bytes) in /home/leanonme/public_html/wp-includes/media.php on line 253
    And the other one is a security issue

    Does any one know about this...and how to fix it.

    Thank you,
    rdf

  10. doodlz
    Member
    Posted 3 years ago #

    Has anyone successfully gotten the child's function.php file to work? I tried New Nine Media's Fix to no avail. I have to get a client's site working and this certainly doesn't help.

  11. niericentral
    Member
    Posted 3 years ago #

    Bump on this question. I get the white screen with a single line functions.php. Absolutely no extra line feeds, carriage returns, etc. I tried deleting the file and putting a new one (again without extra lines) with no effect.

    <?php add_filter(‘widget_title’, ‘do_shortcode’); ?>

    When I go back to anything after the white screen, it seems to have been updated, but it happens all the time with many different parts of wordpress after functions.php is added to the child theme.

    Anyone have an idea?

  12. trivum
    Member
    Posted 3 years ago #

    I'm having the same problem. Any suggestions?

  13. niericentral
    Member
    Posted 3 years ago #

    I haven't worked on that site since the recent WP upgrade. However, with the previous version I was never able to find a solution and just had to do things without functions.php. Maybe this bump will bring in somebody with some insight.

  14. trivum
    Member
    Posted 3 years ago #

    I'm using the most recent upgrade, and it's still happening.

  15. daitya
    Member
    Posted 3 years ago #

    If removing the 'functions.php' file from your child theme means you no longer see the WSOD, then definitely there's a problem with your child theme's 'functions.php' file. It might be, as some have pointed out, a simple matter of white space or empty lines. Or it could be that your code is incorrect (eg. a missing php end tag or possibly one too many). Or it could be that you've missed out on something, such as removing an action hook belonging to the parent theme and replacing it with a new function. I got the WSOD when I neglected to remove_action('widgets_init', 'twentyten_widgets_init' ); before defining new widget areas in my child theme's functions. Remember that the child theme's 'functions.php' always loads before the parent theme's functions.php. Whether your installation is a single WordPress or MU or Multisite, the same rule applies. If your child theme's 'functions.php' file is blank or empty, then it shouldn't be there.

  16. trivum
    Member
    Posted 3 years ago #

    In my case, I even tried uploading the original twentyten functions file (unchanged and untouched) directly from my hard drive. Still no go. There seems to be some systematic problem.

  17. trivum
    Member
    Posted 3 years ago #

    I tried something else recently. I took a TwentyTen theme, changed the name on it in the style.css file, and then made all my changes on my hard drive. I uploaded it as a new theme and activated it, but still got the white screen of death (even in the admin area).

  18. trivum
    Member
    Posted 3 years ago #

    Finally figured this out.

    In my case, I was trying to resize the header. I was copying the complete functions file into the child theme and then changing the header size.

    What worked in the end was copying ONLY the header image size code (not the entire file) into the child theme and changing it.

    For example, the original height of the header was 198px, but I wanted to change it to 100px. So this is what my functions.php file looks like in my child theme (only this):

    <?php
    
    // The height and width of your custom header. You can hook into the theme's own filters to change these values.
    	// Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values.
    	define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 940 ) );
    	define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 100 ) );
    
    ?>
  19. daitya
    Member
    Posted 3 years ago #

    Important point you've made: only put into your child theme's functions any additions or modifications to the parent theme's functions; and in some cases, necessary to use the 'remove_action' to override the parent theme's code. Read more in the codex about child themes and functions.php.

    Glad you've worked it out. : )

  20. Tim Squires
    Member
    Posted 3 years ago #

    Hi, I've been having the same problem as trivum - wanting to change the size of my header in Twentyten. I followed the steps above and created a functions.php file with the exact same code (but with my own header dimensions) and uploaded it to my child theme folder via ftp. I previewed the result in my browser and it looked perfect, but then when I went to log in to my WordPress admin I was blocked out by an error message saying that the functions were coming from the parent theme. When I deleted the new functions.php file from the child theme, I was allowed back in to my admin panel, but, of course, the header reverted back to the original default size. I can change the size in the parent functions.php file, and it works fine. But I would rather have a fully functioning child theme, as this would seem to be optimal best practice - any thoughts on this (I wish I could work it out too!)

  21. daitya
    Member
    Posted 3 years ago #

    Tim, what do you mean by "blocked out by an error message saying that the functions were coming from the parent theme"? Have you got WordPress debugging on? And by blocked out from your admin panel, do you mean the White Screen of Death? Because if this is the case, it's possible that you accidentally left blank spaces or typos in your functions.php, or perhaps the code was wrongly constructed or placed incorrectly...

    For changing header images and sizes, recommend this solution authored by David Cox over at Digital Raindrops.

  22. Tim Squires
    Member
    Posted 3 years ago #

    Hi daitya, sorry for the delay in replying. The error that I am getting when trying to log in to the admin panel is this:

    Warning: Cannot modify header information - headers already sent by (output started at /home/directory info in here/wp-content/themes/twentytenchild/functions.php:1) in /home/directory info in here/wp-includes/pluggable.php on line 897

    It does appear on a white screen - not sure if that is TWOD.

    Thanks for the tips on blanks and typos, I will check
    the code - although it should be OK as I copied it directly from the parent theme (as demonstrated by trivum in the above example. Thanks also for the link to David Cox's solution - I will explore that also.

  23. somethingelse
    Member
    Posted 3 years ago #

    @trivum!! that completely did the trick.

    i think part of the problem is, when overriding a function (as opposed to inserting a new one) all it wants is the actual CHANGES, not the extra parts of the function code.

    i'm no programmer, but i tried every possible configuration to change the header size, assuming that i needed to call the function to begin with... but as in @trivum's solution, only the definitions were needed, not the function twentyten_setup() { bit.

    i did not experience the lock out that @Tim did... copied trivum's code exactly.

    Thanks for the fixes!

  24. membus
    Member
    Posted 3 years ago #

    Dear All,

    Thank you all for your suggestions. Finally after lots of reading and trials and helps from others, I was able to figure out and solve the problem.

    Cheers
    Mehmet

Topic Closed

This topic has been closed to new replies.

About this Topic