如何在WordPress文章裡,讀取並顯示JSON格式的內容或網址呢?(外掛推薦)

在Wordpress文章讀取並顯示JSON格式(外掛)
在開發Web或資訊呈現時,很常遇到需要讀取顯示即時的JSON格式的資料檔案,但是WP好像沒有這個功能,那在編寫WordPress文章的時候要如何解析結構化資料的內容或網址呢?這邊推薦一個好用的外掛!



安裝插件:JSON Content Importer (讀取並顯示JSON外掛)




WordPress讀取JSON格式 教學
STEP1

在Wordpress文章讀取並顯示JSON格式(外掛)1
前往JSON Content Importer,或直接到WordPress後台→外掛→安裝外掛→搜尋JSON Content Importer

STEP2

外掛安裝好後,可以直接在文章中加入碼:(詳細使用方法可以參考:JSON Content Importer 使用文件)
JSON Content Importer

[jsoncontentimporter url="https://..." numberofdisplayeditems="30" basenode="location"] 
<ul><li>{locationid} {street:ifNotEmptyAdd:,} {zipcode} {cityname} <a href="https://.../?q={locationname:urlencode}">search duckduckgo</a> list of events at this location: {subloop:event:5}<a href="{eventlink}">{eventname:ifNotEmptyAdd::} {eventstart}</a><br>{/subloop}<hr>
</li></ul>
[/jsoncontentimporter]
STEP3

資訊就可以顯示在文章中了!如下:
[jsoncontentimporter url=”http://echo.jsontest.com/one/hello/two/techmarks/three/bye” numberofdisplayeditems=”1″]one:{one}
two:{two}
three:{three}
[/jsoncontentimporter]


延伸閱讀:為網站文章加入評分功能(WP外掛)更多WordPress擴充外掛推薦