Title: Issue when adding search form code to functions.php file
Last modified: August 21, 2016

---

# Issue when adding search form code to functions.php file

 *  Resolved [charmies](https://wordpress.org/support/users/charmies/)
 * (@charmies)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/issue-when-adding-search-form-code-to-functionsphp-file/)
 * Hello,
    I was really happy when I managed to add a search form to my main menu
   using the instructions on your site here [http://www.themesandco.com/snippet/adding-an-html5-search-form-in-your-wordpress-menu/](http://www.themesandco.com/snippet/adding-an-html5-search-form-in-your-wordpress-menu/)
 * However, subsequently I had issues logging in to the admin area of WP. When I
   removed this code – and one previous to it – from the functions.php file in my
   child theme, all went back to normal.
 * I have probably missed something obvious here, but any ideas what?
 * // Exclude images from search results – Customizr
    add_action(‘init’, function(){
   remove_filter( ‘pre_get_posts’, array(TC_post_list::$instance, ‘tc_include_attachments_in_search’));});//
   As of 3.1.10, Customizr doesn’t output an html5 form. add_theme_support( ‘html5’,
   array( ‘search-form’ ) );
 * add_filter(‘wp_nav_menu_items’, ‘add_search_form_to_menu’, 10, 2);
    function 
   add_search_form_to_menu($items, $args) {
 *  // If this isn’t the main navbar menu, do nothing
    if( !($args->theme_location
   == ‘main’) ) return $items;
 *  // On main menu: put styling around search and append it to the menu items
    
   return $items . ‘<li class=”my-nav-menu-search”>’ . get_search_form(false) . ”;}

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

 *  [Rocco Aliberti](https://wordpress.org/support/users/d4z_c0nf/)
 * (@d4z_c0nf)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/issue-when-adding-search-form-code-to-functionsphp-file/#post-4860673)
 * What kind of issue?
    Anyway in the code you posted something is missing:
 *     ```
       // On main menu: put styling around search and append it to the menu items
           return $items . '<li class="my-nav-menu-search">' . get_search_form(false) . '</li>';
       ```
   
 * That ending “” .
 *  Thread Starter [charmies](https://wordpress.org/support/users/charmies/)
 * (@charmies)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/issue-when-adding-search-form-code-to-functionsphp-file/#post-4860767)
 * It was the white screen of death!
    So should I try adding this to the end of 
   the code? ”;
 * Thanks
 *  [Rocco Aliberti](https://wordpress.org/support/users/d4z_c0nf/)
 * (@d4z_c0nf)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/issue-when-adding-search-form-code-to-functionsphp-file/#post-4860773)
 * Nope, I said you posted this:
 *     ```
       // On main menu: put styling around search and append it to the menu items
       return $items . '<li class="my-nav-menu-search">' . get_search_form(false) . '';
       }
       ```
   
 * But ElectricFeet’s code was so:
 *     ```
       // On main menu: put styling around search and append it to the menu items
           return $items . '<li class="my-nav-menu-search">' . get_search_form(false) . '</li>';
       ```
   
 * About white screen of death, probably you made some mistake in your functions.
   php, something that happens to all of us, something like a missing semicolon 
   or closing bracket.
 * What I suggest is to enable the debug mode so you can easily see what’s the problem.
   You will see an error printed instead of a white screen of death : [https://codex.wordpress.org/WP_DEBUG](https://codex.wordpress.org/WP_DEBUG)
 *  Thread Starter [charmies](https://wordpress.org/support/users/charmies/)
 * (@charmies)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/issue-when-adding-search-form-code-to-functionsphp-file/#post-4860845)
 * Strangely the closing li in this code didn’t display in my message.
    Debug didn’t
   pick up the problem so I removed all the code in functions.php and starting from
   scratch.

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

The topic ‘Issue when adding search form code to functions.php file’ is closed to
new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/customizr/4.4.24/screenshot.png)
 * Customizr
 * [Support Threads](https://wordpress.org/support/theme/customizr/)
 * [Active Topics](https://wordpress.org/support/theme/customizr/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/customizr/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/customizr/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [charmies](https://wordpress.org/support/users/charmies/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/issue-when-adding-search-form-code-to-functionsphp-file/#post-4860845)
 * Status: resolved