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
Check out
WP::parse_request()
– unfortunately, it was never really designed for public use. You could try this, not sure of the repercussions:While the question of processing links is interesting on its own, I think for the Ajax use case it would be more simple and reliable to output more specific information in page body as JS variable that Ajax would submit.
Common current practice for such is to use
wp_localize_script()
to pass data.