Temporarily storing main search result

The way I see it, you have three options:

  1. Store the global search data in $_SESSION
  2. Store the global data in a transient
  3. Run the query twice, with & without the post type filter

I tried storing the array in a global variable and as soon as the page refreshes with the refined search results, the array shows NULL.

Of course. PHP has no “memory” of the previous request, that’s the curse of HTTP.

Personally, I would opt for option 1 or 2. 3 is okay but more intensive on the server – it all depends on the level of traffic and how many concurrent searches you expect to handle.