Andrei Marinescu
Andrei Marinescu

Reputation: 21

JSONP Wordpress API

I need to call from a wordpress page, the content that I can edit in wp-admin on that page. It's a page, and not a post.

Can anyone provide me with the code that I need to access the WP JSON API? It needs to be JSONP as the call is made from a HTML hosted on another server. I found this WP plugin: http://wordpress.org/extend/plugins/json-api/

Thanks in advance!

Andrei

Upvotes: 2

Views: 2769

Answers (1)

mccannf
mccannf

Reputation: 16659

According to that API, you specify get_page and the page id, like so:

var page_id = 11111;

$.ajax({
        url: 'http://www.example.org/?json=get_page&page_id='+page_id+'&callback=?',
        dataType: 'jsonp',
        type: 'GET',
        success: function(data) {
               alert("Title of page retrieved: "+data.page.title);
               console.log(JSON.stringify(data));
        }
});

Upvotes: 3

Related Questions