[wp-hackers] $wp_query Disappears after AJAX

Vinicius Massuchetto viniciusandre at gmail.com
Thu Apr 1 19:07:18 UTC 2010


On Thu, Apr 1, 2010 at 3:54 PM, Spencer <spencer.gurnk at gmail.com> wrote:
> Hey everyone,
>
> I'm not sure if this is a bug, or I'm doing something completely wrong, but
> I'm in a bit of a pickle.
>
> I'm trying to merge an array of arguments (that I created) with the original
> $wp_query->query array. It's fine the first time it loads (just calling the
> function directly), but then once it gets updated with AJAX (the same
> function is called through add_action( 'wp_ajax_callback', 'callback' );),
> the $wp_query variable seems to disappear. Any ideas why that would make it
> mess up?
>
> I've tried everything I can think of. I've tried making temporary versions
> of $wp_query and restoring it, wp_reset_query, and a million combinations of
> other things.

Calling an AJAX request implies of having another timeline on page
loading, like loading another page. AFAIK, it only posts something
again to a webpage, needing new queries and stuff to be loaded if you
need them.

You can assign $_SESSION variables, or use the $_POST variables to
load some info again if you need something pre-loaded for this AJAX
request.

Hope it helps.
--
Vinicius Massuchetto
http://vinicius.soylocoporti.org.br


More information about the wp-hackers mailing list