Discussion:
Fetching posts by URL
Joshua Sibelman
2013-11-07 16:06:14 UTC
Permalink
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
John
2013-11-08 01:07:36 UTC
Permalink
Tareq Hasan has done a proof of concept theme using Backbone.js and the
JSON API plugin by Ryan McCue. Here's the Github repo for it, and there's a
link to his site for more info and a demo.
https://github.com/tareq1988/wp-backbone


On Thu, Nov 7, 2013 at 11:06 AM, Joshua Sibelman
Post by Joshua Sibelman
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
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Loading...