Firstly this question is different to this one as I'm talking about accessing $Wp_Query from outside of a loop.
What I'm trying to do
I'm currently just attempting to make an ajax request from a script to a php file called database.php
which looks like so.
if (isset($_GET["increase"])) {
global $wp_query;
echo var_dump($wp_query);
}
As seen I'm just trying to get anything from the $wp_query this is the output from log.
XHR finished loading: GET "http://localhost/WCBD/wp-content/themes/Test%20Computing/database.php?increase=1".jquery.js?ver=1.11.1:4 m.ajaxTransport.sendjquery.js?ver=1.11.1:4 m.extend.ajaxjquery.js?ver=1.11.1:4 m.each.m.(anonymous function)myscripts.js?ver=1.2:15 foo.vote_up(index):313 onclick
myscripts.js?ver=1.2:11
NULL
So it seems that it loaded correctly.
I feel like I'm missing an obvious step or something at being able to access the $wp_query.
Thank you.