[wp-hackers] Building a JSON API style plugin
Tom Barrett
tcbarrett at gmail.com
Thu Nov 3 06:32:53 UTC 2011
On 3 November 2011 05:47, Andrew Spratley <aspratley at gmail.com> wrote:
> Does this help http://wordpress.org/extend/plugins/json-api/ ?
>
Mmm.. yes and no. :) None of the ticket data is stored in the local
WordPress database, so it can't be too reliant on using wp_posts.
> On Wed, Nov 2, 2011 at 7:38 PM, Otto <otto at ottodestruct.com> wrote:
> > If it was something I was putting in a plugin or releasing, then
> > template_redirect is where I'd generally put it, with some additional
> > rewrite rules to make the URLs pretty. This is fairly easy to do,
> > actually. Say you wanted to have the URLs look like /ticket/12345:
> >
> > add_action('init','ticket_add_rewrite');
> > function ticket_add_rewrite() {
> > global $wp;
> > $wp->add_query_var('ticket');
> > add_rewrite_rule('ticket/([0-9]+)/?$',
> > 'index.php?ticket=$matches[1]', 'top');
> > }
>
I think this is the little gem I'm looking for. That looks really simple
and can easily handle grabbing data from a non WordPress database.
--
http://www.tcbarrett.com | http://gplus.to/tcbarrett |
http://twitter.com/tcbarrett
More information about the wp-hackers
mailing list