title: Wrong URL on search with $wp_query with pagination
body: <p>I have a code from a developer that uses custom pagination for displaying pages for search results. Once the search is run, the script seems to wrongly generate urls for next search pages (as of 2 page).</p>
  
  <p>The url adds title of one of the documents, retrieved during search, before "..../page/2", so like that:</p>
  
  <blockquote>
    <p>www.website.com/document/title_of_one_retrieved_in_page_1_documents/page/2</p>
  </blockquote>
  
  <p>I am just a novice in WP, so any help/advice is greatly appreciated.</p>
  
  <pre><code>
  </code></pre>