WP REST API (http://v2.wp-api.org)에서 확인할 수 있습니다. 이것은 정확히 당신이 찾고있는 것입니다. WP REST API를 사용하면 관리하는 사이트에서 EVERY 게시물 요소를 가져 와서 다른 사이트에 표시 할 수 있습니다. (그러나 당신은 또한 인증의 형태를 구현해야합니다!)
예 요청 :
가
http://www.example.com/wp/wp-json/wp/v2/venue
"개최지"나는 실제 코드에서 사용하는 사용자 정의 포스트 유형입니다. 예제 요청은 사이트에서 모든 장소를 확보하도록 만들어졌습니다.
예 응답 :
[
{
"id": 20,
"date": "2016-06-08T16:37:23",
"date_gmt": "2016-06-08T16:37:23",
"guid": {
"rendered": "http://www.example.com/wp/?post_type=venue&p=20"
},
"modified": "2016-06-20T11:45:22",
"modified_gmt": "2016-06-20T11:45:22",
"slug": "aquarium-club",
"type": "venue",
"link": "http://www.example.com/wp/venue/aquarium-club/",
"title": {
"rendered": "Aquarium Club"
},
"content": {
"rendered": "<p>Aquarium Club. That’s OK. 7765e546uzfkjglh</p>\n<p> </p>\n<style>\n.gmap-iframe-container {\nmax-width: 100%;\n}\n.gmap-iframe {\nwidth: 100%;\nheight: 200px;\nmin-width:100%;\n}\n</style>\n<div class=\"gmap-iframe-container\">\n<iframe src=\"https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d2695.565888030695!2d19.052103115616678!3d47.49836967917771!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x4741dc402a04eee3%3A0x6869564cd433693c!2sAkv%C3%A1rium+Klub!5e0!3m2!1shu!2shu!4v1466147278469\" frameborder=\"0\" style=\"border:0\" allowfullscreen class=\"gmap-iframe\"></iframe></p>\n"
},
"excerpt": {
"rendered": "<p>Aquarium Club. That’s OK. 7765e546uzfkjglh </p>\n"
},
"featured_media": 0,
"menu_order": 0,
"format": "standard",
"tags": [],
"meta_data": {
"youtube_embed": "https://www.youtube.com/embed/xBW7DglTDGs"
},
"_links": {
"self": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/venue/20"
}
],
"collection": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/venue"
}
],
"about": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/types/venue"
}
],
"wp:attachment": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/media?parent=20"
}
],
"wp:term": [
{
"taxonomy": "post_tag",
"embeddable": true,
"href": "http://www.example.com/wp/wp-json/wp/v2/tags?post=20"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
}
},
{
"id": 18,
"date": "2016-06-08T15:55:04",
"date_gmt": "2016-06-08T15:55:04",
"guid": {
"rendered": "http://www.example.com/wp/?post_type=venue&p=18"
},
"modified": "2016-06-08T15:55:04",
"modified_gmt": "2016-06-08T15:55:04",
"slug": "durer-kert",
"type": "venue",
"link": "http://www.example.com/wp/venue/durer-kert/",
"title": {
"rendered": "Dürer Kert"
},
"content": {
"rendered": ""
},
"excerpt": {
"rendered": ""
},
"featured_media": 19,
"menu_order": 0,
"format": "standard",
"tags": [],
"meta_data": {
"youtube_embed": "https://www.youtube.com/embed/w9saGGpnKlk"
},
"_links": {
"self": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/venue/18"
}
],
"collection": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/venue"
}
],
"about": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/types/venue"
}
],
"wp:featuredmedia": [
{
"embeddable": true,
"href": "http://www.example.com/wp/wp-json/wp/v2/media/19"
}
],
"wp:attachment": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/media?parent=18"
}
],
"wp:term": [
{
"taxonomy": "post_tag",
"embeddable": true,
"href": "http://www.example.com/wp/wp-json/wp/v2/tags?post=18"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
}
},
{
"id": 15,
"date": "2016-06-08T14:52:40",
"date_gmt": "2016-06-08T14:52:40",
"guid": {
"rendered": "http://www.example.com/wp/?post_type=venue&p=15"
},
"modified": "2016-06-08T15:41:27",
"modified_gmt": "2016-06-08T15:41:27",
"slug": "kobuci-kert",
"type": "venue",
"link": "http://www.example.com/wp/venue/kobuci-kert/",
"title": {
"rendered": "KOBUCI Kert"
},
"content": {
"rendered": "<p>This is KOBUCI Kert.</p>\n"
},
"excerpt": {
"rendered": "<p>This is KOBUCI Kert.</p>\n"
},
"featured_media": 17,
"menu_order": 0,
"format": "standard",
"tags": [],
"meta_data": {
"youtube_embed": "https://www.youtube.com/embed/zwNBKh6ghOY"
},
"_links": {
"self": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/venue/15"
}
],
"collection": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/venue"
}
],
"about": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/types/venue"
}
],
"wp:featuredmedia": [
{
"embeddable": true,
"href": "http://www.example.com/wp/wp-json/wp/v2/media/17"
}
],
"wp:attachment": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/media?parent=15"
}
],
"wp:term": [
{
"taxonomy": "post_tag",
"embeddable": true,
"href": "http://www.example.com/wp/wp-json/wp/v2/tags?post=15"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
}
},
{
"id": 13,
"date": "2016-06-08T14:12:38",
"date_gmt": "2016-06-08T14:12:38",
"guid": {
"rendered": "http://www.example.com/wp/?post_type=venue&p=13"
},
"modified": "2016-06-08T14:12:38",
"modified_gmt": "2016-06-08T14:12:38",
"slug": "mupa",
"type": "venue",
"link": "http://www.example.com/wp/venue/mupa/",
"title": {
"rendered": "MÜPA"
},
"content": {
"rendered": "<p>MÜPA is MÜPA. Not bad from a building, is it? A lot of concerts and stuff.</p>\n"
},
"excerpt": {
"rendered": "<p>MÜPA is MÜPA. Not bad from a building, is it? A lot of concerts and stuff.</p>\n"
},
"featured_media": 14,
"menu_order": 0,
"format": "standard",
"tags": [],
"meta_data": {
"youtube_embed": "https://www.youtube.com/embed/YnOW2rUXuSg"
},
"_links": {
"self": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/venue/13"
}
],
"collection": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/venue"
}
],
"about": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/types/venue"
}
],
"wp:featuredmedia": [
{
"embeddable": true,
"href": "http://www.example.com/wp/wp-json/wp/v2/media/14"
}
],
"wp:attachment": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/media?parent=13"
}
],
"wp:term": [
{
"taxonomy": "post_tag",
"embeddable": true,
"href": "http://www.example.com/wp/wp-json/wp/v2/tags?post=13"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
}
},
{
"id": 8,
"date": "2016-06-07T08:36:40",
"date_gmt": "2016-06-07T08:36:40",
"guid": {
"rendered": "http://www.example.com/wp/?post_type=venue&p=8"
},
"modified": "2016-06-08T13:22:39",
"modified_gmt": "2016-06-08T13:22:39",
"slug": "some-venue",
"type": "venue",
"link": "http://www.example.com/wp/venue/some-venue/",
"title": {
"rendered": "National Concert Hall"
},
"content": {
"rendered": "<p>This is the next venue for REST API. Just to see more than one. This should be the general description of this venue. This is the venue – what is it? 5324</p>\n"
},
"excerpt": {
"rendered": "<p>This is the next venue for REST API. Just to see more than one. This should be the general description of this venue. This is the venue – what is it? 5324</p>\n"
},
"featured_media": 9,
"menu_order": 0,
"format": "standard",
"tags": [],
"meta_data": {
"youtube_embed": "https://www.youtube.com/embed/camVVzjGheQ"
},
"_links": {
"self": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/venue/8"
}
],
"collection": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/venue"
}
],
"about": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/types/venue"
}
],
"wp:featuredmedia": [
{
"embeddable": true,
"href": "http://www.example.com/wp/wp-json/wp/v2/media/9"
}
],
"wp:attachment": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/media?parent=8"
}
],
"wp:term": [
{
"taxonomy": "post_tag",
"embeddable": true,
"href": "http://www.example.com/wp/wp-json/wp/v2/tags?post=8"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
}
},
{
"id": 7,
"date": "2016-06-07T08:33:13",
"date_gmt": "2016-06-07T08:33:13",
"guid": {
"rendered": "http://www.example.com/wp/?post_type=venue&p=7"
},
"modified": "2016-06-08T13:20:27",
"modified_gmt": "2016-06-08T13:20:27",
"slug": "orchestra-hall",
"type": "venue",
"link": "http://www.example.com/wp/venue/orchestra-hall/",
"title": {
"rendered": "Music Academy"
},
"content": {
"rendered": "<p>This is a venue – it is made of a custom post type, and I get it with REST API.</p>\n"
},
"excerpt": {
"rendered": "<p>This is a venue – it is made of a custom post type, and I get it with REST API.</p>\n"
},
"featured_media": 11,
"menu_order": 0,
"format": "standard",
"tags": [],
"meta_data": {
"youtube_embed": "https://www.youtube.com/embed/ZL6BFCxNGZ8"
},
"_links": {
"self": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/venue/7"
}
],
"collection": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/venue"
}
],
"about": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/types/venue"
}
],
"wp:featuredmedia": [
{
"embeddable": true,
"href": "http://www.example.com/wp/wp-json/wp/v2/media/11"
}
],
"wp:attachment": [
{
"href": "http://www.example.com/wp/wp-json/wp/v2/media?parent=7"
}
],
"wp:term": [
{
"taxonomy": "post_tag",
"embeddable": true,
"href": "http://www.example.com/wp/wp-json/wp/v2/tags?post=7"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
}
}
]
참고 : 이 - 위의 예제 결과가 내 요구에 맞게 사용자 정의 비트입니다 - 그래서 당신은 조금 다른 결과를 볼 수 있습니다. 당신은 당신이 다른 사이트에서 필요한 정보의 모든 조각을 얻을 수 있습니다 볼 수 있듯이
http://www.example.com/wp/wp-json/wp/v2/venue/20
- 당신은 당신의 마음에 드는에 대한 응답을 사용자 정의 할 수 있습니다 : - 는 하나의 장소에 대한 요청은 다음과 같을 것 .
빠른 답장을 보내 주셔서 감사합니다. 이전에 다른 API를보고 나서 이전에 Rest API를보고있었습니다. 1-10의 척도에서, 내가 설명한 것처럼 실제로 코드를 업데이트하여 복잡성을 어느 정도 평가합니까? 나는 PHP에 익숙하지만 꽤 복잡한 것처럼 보입니다. 이견있는 사람? – mg33
1-10까지? REST API는 플러그인입니다 (실제로 WP 4.5에서 WP 코어 기능이 될 예정이었습니다). 그래서 설치하는 것은 케이크 조각입니다. 그런 다음 API 페이지 (및 기타 자습서)는 원하는 데이터를 가져 오는 데 필요한 많은 예제 코드를 제공합니다. 화면에서 응답을 볼 수 있으면 원하는 위치에 배열 요소를 배치하고 서식을 지정하는 게임이 될 것입니다. .결과를보기 위해 일부 테스트 소프트웨어 (Chrome 용 우편 게시자 확장 프로그램을 사용)를 사용하는 것이 좋습니다. 인증은 또 다른 문제입니다 - 당신이 선택한 유형에 따라 어려울 수 있습니다. –
또 하나의 질문입니다. REST API를 사용하여 내가 설명한 것을 수행하고 다른 사이트의 게시물을 해당 특정 사이트에 단순히 연결하는 것이 가능하다고 생각합니까? 예 : 블로그 A에서 블로그 B 게시물에 대한 링크를 클릭하면 블로그 B가 해당 게시물 세부 정보 페이지에서 열립니다. – mg33