I have this function somewhere in my code... what this would do is make my site accept params a and slug. Something like site.com/?a=do_this&slug=page to change the display of the site. Currently, I've just make it to display a simple text.
add_filter( 'query_vars', array( $this, 'addQueryVariables' ) );
add_action( 'template_redirect', array( $this, 'the_request' ) );
public function addQueryVariables($queryVariables) {
$queryVariables = array_merge($queryVariables, array(
'a',
'slug',
));
retu $queryVariables;
}
public function the_request() {
if ( get_query_var('a') ) {
$this->do_this_function(array(
'action' => get_query_var('a'),
'slug' => get_query_var('slug'),
));
}
}
It works fine viewing site.com/?a=do_this&slug=page. I get the result as expected. But if I use wp_remote_get, I get the homepage html and not the simple text I wanted.
I use something like this to check.
$url = 'site.com/?a=do_this&slug=page';
$options = array(
'timeout' => 10, //seconds
'headers' => array(
'Accept' => 'application/json'
),
);
$result = wp_remote_get(
$url,
$options
);
print_r($result);die();
it prints the whole html of the homepage in $result[body]
