My home.php shows a list of (N) posts and << Previous & Next >> links. When clicked, I want to fetch previous/next list of (N) posts using Ajax. This is: I do NOT want to load the entire page. I just want to get the posts' list and append it to current.

For this I make an ajax request and send href (URL) as parameter. The problem is I do not know how WordPress converts a URL to global $query_string. I want to reuse WordPress' tested code instead of writing my own. Please help

For example: I want to fill $query_string for this URL: http://example.com/page/2/?location=boston

link|improve this question

79% accept rate
feedback

2 Answers

Check out WP::parse_request() - unfortunately, it was never really designed for public use. You could try this, not sure of the repercussions:

global $wp,
       $wp_the_query;

// Grab the request_uri component of the referer URL.
if ( ! $url = parse_url( $_GET['my_referer_parameter'] ) )
    return 'Oh dear, poorly formed referer.';

// Ewww! Trick WP::parse_request by spoofing REQUEST_URI. 
$_SERVER['REQUEST_URI'] = $url['path'] . "?{$url['query']}";

$wp->parse_request();
$wp->query_posts();

// $wp_the_query should now be populated with posts queried by your referer.
while ( $wp_the_query->have_posts() ) {

    $wp_the_query->the_post();
    the_title();

}
link|improve this answer
feedback

I think one of these plugins might do what you want:

https://wordpress.org/extend/plugins/monkeyman-rewrite-analyzer/ http://www.askapache.com/htaccess/rewriterule-viewer-plugin.html

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.