More Related Content
Similar to WordPress REST API (20)
WordPress REST API
- 6. «We need to work hard to harmonize the REST API plugin
And the WordPress.com REST API»
- 9. получить все записи
GET /wp-json/posts
получить записи из категории 1
GET /wp-json/posts?filter[cat]=1
получить запись по ID
GET /wp-json/posts/123
- 12. 1. Cookie
2. OAuth1 (OAuth plugin + WP-CLI)
3. HTTP Basic Auth (Basic Auth plugin
POST PUT DELETE
* изменяем запись с ID 1234
- 14. Cookie-авторизация / JavaScript-запросы
wp_enqueue_script( ‘wp_api’ );
jQuery.ajax({
url: WP_API_Settings.root + ‘/posts/1234’
,method: ‘PUT’
,beforeSend: function(xhr) {
xhr.setRequestHeader(‘X-WP-Nonce’, WP_API_Settings.nonce)
}
,contentType: ‘application/json’
,dataType: ‘json’
,data: {ID: 1234, title: ‘sometitle’, content_raw: ‘text’}
});
Объект WP_API_Settings