
內容簡介
如果你常常寫關於當地地點的部落格文章,你可能希望為你的使用者提供營業時間、電話號碼和地址等資訊。但是,這樣的資訊往往很難維持最新。幸運的是,谷歌提供了一個名為 Google Places API Web Service 的應用程式介面。Google Places API Web Service 可以讓你新增有關數百萬個位置的最新資訊。
WP_Places 外掛需要一個 Google Places API Web Service 金鑰。然而,在撰寫本文時,API 金鑰是免費的,並且每 24 小時提供多達 1,000 個請求。如果你驗證你的身份(提供信用卡給 Google),他們將會將你每天可以發出的請求次數提高至 150,000。
安裝 WP_Places 後,你只需提供名稱和位置,就可以顯示包含商家名稱、地址、營業時間、電話號碼和網站的 DIV。
以下是可用的短碼:
[wp_places name] 顯示 Google Places 名稱
[wp_places formattedAddress] 以區域標準化方式顯示地址
[wp_places phoneNumber] 以區域標準化方式顯示電話號碼
[wp_places hours] 以列表形式顯示營業時間
[wp_places website] 顯示網站
[wp_places priceLevel] 以 Google Places API 所規定的價位等級返回價格等級
[wp_places rating] 以 Google Places API 所規定的平均評分返回平均評分
[wp_places lat] 緯度
[wp_places lng] 經度
[wp_places openNow] 如果正在營業,就返回 1
[wp_places openNowText] 如果正在營業,就返回 "Open Now"
[wp_places permanentlyClosed] 如果永久關閉,就返回 1
[wp_places photos] 如果 Google 提供照片,就返回照片
[wp_places reviews] 如果 Google 提供評論,就返回評論的 UL 列表
你可以使用篩選器來過濾 Google 回復的緩存時間:
add_filter( 'wp_places_transient', 'wp_places_update_transient', 10, 1 );
wp_places_update_transient( $time ) {
// 以秒為單位返回一個緩存時間
return 86400; // 一天
return 604800 // 一週
}
外掛標籤
開發者團隊
📦 歷史版本下載
原文外掛簡介
If you find you regularly write blog posts about (local?) places you might want to provide info such as hours, phone number, address to your users. However, this can be difficult to keep current. Fortunately Google offers an API called Google Places API Web Service. Google Place API Web Service allows you to Add up-to-date information about millions of locations.
WP_Places Plugin requires a Google Places API Web Service Key. However, at the time of writing the API key is free and provides up to 1,000 requests per 24 hour period. If you verify your identity (by providing Google a Credit Card) they will increase your daily request per 24 hours to 150,000.
Once Installed, WP_Places takes name and location and displays a DIV containing Business Name, Address, Hours, Phone Number, Website.
The following shortcodes are available:
[wp_places name] displays the Google Places name
[wp_places formattedAddress] displays the address in the regionally standardized way
[wp_places phoneNumber] displays the phone number in the regionally standardized way
[wp_places hours] displays the hours of operation in a list
[wp_places website] displays the website
[wp_places priceLevel] returns the pricing level as prescribed in google places API
[wp_places rating] returns the average rating as prescribed in google places API
[wp_places lat] lattitude
[wp_places lng] longitude
[wp_places openNow] returns 1 if open
[wp_places openNowText] returns “Open Now” if open
[wp_places permanentlyClosed] returns 1 if permanently closed
[wp_places photos] returns photos if google supplies them
[wp_places reviews] returns a UL list of reviews if google supplies them
To filter how long to cache the google reply there is a filter:
add_filter( ‘wp_places_transient’, ‘wp_places_update_transient’, 10, 1 );
wp_places_update_transient( $time ) {
// return a value in seconds for how long to cache.
return 86400; // one day
return 604800 // one week
}
