[wp-hackers] Fetching posts by URL

Joshua Sibelman joshua.sibelman at gmail.com
Thu Nov 7 16:06:14 UTC 2013


Looking for opinions on an approach for building a single page WP site, where WP is used as a CMS, e.g. many CPTs, posts 2 posts, etc.

Ideally I'd be able to have all the links point to their respective posts' permalinks, with JavaScript intercepting the clicks and passing the path to a custom controller for the JSON API plugin. This way spiders can still crawl the site, and I can use progressive enhancement to remove the full page reloads.

What I want to be able to do is the same kind of processing done by WP->parse_request, but that method relies on analyzing the URL visited in the browser.

It seems I could either try to reproduce that method to handle a provided path, or I could try using data attributes in the href tags which the JavaScript could pass to the JSON API as arguments to get the correct resource.

Has anyone else done something like this? Does anyone have an opinion as to which method might be best? I have also considered using get_page_by_path, but we are doing some idiosyncratic things with how some of the data is organized and I'm worried that would be more complicated than either of the above approaches.

Cheers,
Josh


More information about the wp-hackers mailing list