Title: Add code to search.php
Last modified: September 1, 2016

---

# Add code to search.php

 *  [meravjon](https://wordpress.org/support/users/meravjon/)
 * (@meravjon)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/add-code-to-searchphp/)
 * Hi
    Same issue that I wrote before with no reply Please, I need to resolve this.
   I bought JIG pluggin, and installed it. But in order to get search results I 
   need to:
 * > Add the following code to your theme’s search.php file, after the line where
   > the content wrapper div starts, before any result gets shown with a loop. For
   > your information, the JIG shortcodes will do the following:
 * this is the code:
 *     ```
       <?php
           global $wp_query, $query_string;
   
           if(!empty($wp_query->query_vars['jig_custom_search'])){
               $jig_custom_search = $wp_query->query_vars['jig_custom_search'];
               $search_value = $wp_query->query_vars['s'];
               echo do_shortcode("If you didn't find what you were looking for, try a new search!<br/><br/>[jig_custom_search_form source=".$jig_custom_search."]<br/><br/>");
               switch ($jig_custom_search) {
                   case 'nextgen':
                       get_jig(array('ng_search_query' => $search_value));
                       break;
   
                   case 'flickr':
                       get_jig(array('limit' => '200', 'flickr_search_text' => $search_value, 'flickr_search_user' => '9563763@N08'));
                       break;
   
                   default:
                       break;
               }
   
               echo '<style type="text/css">
                       .post-content {
                           display: none;
                       }
                   </style>
                   <script type="text/javascript">
                       jQuery(".jigErrorMessage").text("No content found.")
                   </script>';
   
               $wp_query = new WP_Query();
               $query_string = '';
           }
       ?>
       ```
   
 * So how can I do that. I’m using child theme.

Viewing 1 replies (of 1 total)

 *  [Menaka S.](https://wordpress.org/support/users/menakas/)
 * (@menakas)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/add-code-to-searchphp/#post-7651069)
 * Hi,
    Add this to your child theme’s functions.php and make suitable changes.
 *     ```
       add_filter('__before_loop','my_search_code');
   
       function my_search_code($content) {
         if(! is_search()) {
            return $content;
         }
         //ADD YOUR CODE HERE
          return $content;
       }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Add code to search.php’ 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/)

 * 1 reply
 * 2 participants
 * Last reply from: [Menaka S.](https://wordpress.org/support/users/menakas/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/add-code-to-searchphp/#post-7651069)
 * Status: not resolved