Title: functions.php Bug in theme
Last modified: August 20, 2016

---

# functions.php Bug in theme

 *  Resolved [roclimb](https://wordpress.org/support/users/roclimb/)
 * (@roclimb)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/functionsphp-bug-in-theme/)
 * I just made my first theme and added a functions.php file after testing it because
   I needed to add a custom navigation menu plugin. All I put in the function.php
   file was
 * <?php
 * /* Theme Mega Menu. */
    function register_my_menus() { register_nav_menus( array(‘
   header-menu’ => __( ‘Header Menu’ ) ) ); } add_action( ‘init’, ‘register_my_menus’);
 * ?php>
 * this is all that is in the themes functions.php and everything worked fine to
   let me add the menu plugin but when I go into my editor to update a page of my
   theme, it updates but makes the whole page in my wordpress dashboard go completely
   blank(white). If I go back everything on my site updates and is fine but anytime
   I update this bug happens. If I remove functions.php from my theme everything
   is back to normal.
 * What should I do to fix this? Do I need to cenfig my functions file with something
   or add more statements of some sort.
 * Thanks for your patience as this is my first theme ever.

Viewing 8 replies - 1 through 8 (of 8 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/functionsphp-bug-in-theme/#post-2683972)
 * [Turn debug on](http://codex.wordpress.org/Editing_wp-config.php#Debug) and [enable error logging](http://codex.wordpress.org/Editing_wp-config.php#Configure_Error_Log).
 *  [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * (@adeptris)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/functionsphp-bug-in-theme/#post-2683980)
 * Hi,
    functions.php is the **only theme file that does not** require a closing
   php tag <?php ?>
 * You have some bad php code the last line **?php>**, a closing tag would be ?>,
   but not required in this file!
 * Does the plugin say you need to add this code to functions.php, if so which plugin
   is it?
 * It should be more like this:
 *     ```
       <?php
       /* Theme Mega Menu. */
        function register_my_menus() {
        register_nav_menus(
       	array( 'header-menu' => __( 'Header Menu' ) )
       	);
        }
        add_action( 'init', 'register_my_menus' );
       ```
   
 * Do you really need a plugin or is this something you can do without, adding the
   styles etc, here is my [example child theme](http://digitalraindrops.net/2011/09/twenty-eleven-three-menus/)?
 * HTH
 * David
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/functionsphp-bug-in-theme/#post-2683991)
 * > functions.php is the only theme file that does not require a closing php tag
 * Um – I beg to differ. No .php file actually needs a closing `?>` at the very 
   end of it. 🙂
 *  [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * (@adeptris)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/functionsphp-bug-in-theme/#post-2684027)
 * Hi Esmi,
    The OP did have a bad tag in the code.
 * Closing php tag is not a php requirement but a WordPress [Coding Standard](http://core.trac.wordpress.org/ticket/12307)
 * Quote from Nancin
 * > It is the WordPress coding standard to include closing PHP tags on files that
   > are not expected to be edited.
   > **That excludes a theme’s functions.php and wp-config.php.**
   > The ‘headers already sent’ argument only works for those files. **All core 
   > files should not be edited, and should have closing tags.**
 * WordPress Codex [headers already sent errors](http://codex.wordpress.org/FAQ_Troubleshooting#How_do_I_solve_the_Headers_already_sent_warning_problem.3F)
 * >  1. Download the file mentioned in the error message via FTP or the file manager
   > provided in your host’s control panel.
   >  2. Open that file in a plain text editor(
   > NOT MS Word or similar. Notepad or BBEdit are fine). 3. Check that the very
   > first characters are <?php 4. Check that the very last characters are ?>
 * I learnt php via WordPress and do not use it outside of WordPress, so that is
   where I picked up the advice in the past, but it is good to know that they are
   not required Per se.
 * Cheers
 * David
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/functionsphp-bug-in-theme/#post-2684031)
 * It’s a standard for core devs but not for themes & plugins. As one of the Trac
   commentators said, it’s a coding style. And one that has a valid argument in 
   it’s favour – it avoid “header already sent” issues. But either way, it’s certainly
   not a PHP requirement and its absence will not cause any issues.
 *  [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * (@adeptris)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/functionsphp-bug-in-theme/#post-2684033)
 * Cool,
    It seems a standard that most plugin and theme developers seem to use,
   I did not know it was not a requirement, but it seems to be a good practice.
 * If it is a WordPress coding standard then themes and plugins should really follow
   suit, for code consistancy when other developers are starting out and looking
   at code.
 * Back to the topic **?php>** is not valid in this case.
 * David 🙂
 *  Thread Starter [roclimb](https://wordpress.org/support/users/roclimb/)
 * (@roclimb)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/functionsphp-bug-in-theme/#post-2684246)
 * Thnaks so much for the help. I took out the closing tag and everything works 
   perfectly now.
 * Thanks both Digital Raindrops and Esmi for taking the time to help.
    Cheers Rob
 *  [AMSguy](https://wordpress.org/support/users/amsguy/)
 * (@amsguy)
 * [14 years ago](https://wordpress.org/support/topic/functionsphp-bug-in-theme/#post-2684282)
 * I am so glad I found this thread as this just happened to me moments ago, I was
   pulling my hair out! After reading here I yanked the closing tag and my Update
   and Publish buttons in admin worked like they’re supposed to. Having done just
   enough PHP outside of WP to be dangerous I was totally unaware that you could
   leave out closing tags.
 * Gotta love WordPress.org Support Forums;)

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘functions.php Bug in theme’ is closed to new replies.

 * 8 replies
 * 4 participants
 * Last reply from: [AMSguy](https://wordpress.org/support/users/amsguy/)
 * Last activity: [14 years ago](https://wordpress.org/support/topic/functionsphp-bug-in-theme/#post-2684282)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
