title: Adding a search form inside a div in Wordpress
body: <p>I wanted to add a search form inside a div using the code bellow:</p>
  
  <p><code>printf( '&lt;div class="entry"&gt;&lt;p&gt;%s&lt;/p&gt;%s&lt;/div&gt;', apply_filters( 'genesis_noposts_text', __( 'Try again below.', 'genesis' ) ), get_search_form() );</code></p>
  
  <p>But every time I add the <code>get_search_form()</code> it's generated before the div, like the following:</p>
  
  <pre><code>&lt;form&gt;&lt;/form&gt;
  &lt;div class="entry"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>The workaround I found was to split the code, but I wanted to know if there is a better solution that works properly.</p>
  
  <pre><code>remove_action( 'genesis_loop_else', 'genesis_do_noposts' );
  add_action( 'genesis_loop_else', 'mytheme_do_noposts' );
  function mytheme_do_noposts() {
  
      printf( '&lt;div class="entry"&gt;&lt;p&gt;%s&lt;/p&gt;', apply_filters( 'genesis_noposts_text', __( 'Try again below.', 'genesis' ) ) );
  
      printf( '%s&lt;/div&gt;', get_search_form() );
  
  }
  </code></pre>
  
  <hr>
  
  <p><a href="https://developer.wordpress.org/reference/functions/get_search_form/" rel="nofollow noreferrer">get_search_form documentation</a></p>