前提・実現したいこと
word press rest apiを利用して
word pressで作成した固定ページを取得して表示したい。
ブラウザ上で実現したく、jquery + ajax で取得し
htmlを書き換えて表示することを目指しています。
固定ページで作ったLP(ランディングページ)を、別のWEBアプリで表示することを目的としています
発生している問題・エラーメッセージ
contentのrenderedに、謎のタグが表示されるのみで、本文が取得できません。
こういうった仕様なのか、設定や取得方法が間違っているのかご存知の方がいたら教えていただきたいです。
json
1content:{ 2rendered: <div style="font-size:0px;height:0px;line-height:0px;margin:0;padding:0;clear:both"></div> 3protected:false 4}
該当のソースコード
下記のようなコードで取得&表示しようとしています。
※ 一部抜粋
js
1 var api_url = site_url + 'wp-json/wp/v2/pages/123' 2 3$.ajax({ 4 type: 'GET', 5 url: api_url, 6 dataType: 'json' 7 }).done(function (json) { 8 $(".article") 9 .append('<dl class="col-md-4 border border-primary border-top-0 border-right-0 border-bottom-0" style="">' + 10 '<dt>' + json.title.rendered + '</dt>' + 11 '<dd>' + 12 '<div>' + json.content.rendered + '</div>' + 13 '</dd>' + 14 '</dl>' 15 ); 16 }).fail(function (json) { 17 $('.article').append('読み込みエラー'); 18 }); 19
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/05/22 12:23
2018/05/24 10:58