內容簡介
這款外掛旨在供其他開發人員與主題和其他外掛一起使用。許多主題和外掛使用 WordPress 元數據表來存儲文章的經度和緯度坐標。雖然這很好用,但是元數據表無法很好地進行索引。例如,你已經創建了一個名為“房產”的自定義文章類型,並連接了10萬條經緯度坐標。你希望用戶在50英里的範圍內搜索這些房產。因為 WordPress 存儲元數據的方法,當處理大量數據時,查詢會變得很慢。
這個插件可應用於當前的 WordPress 安裝中。開發人員使用篩選器選擇要開始捕獲的 meta 數據,並且此插件會將數據放入更好地優化存儲經度和緯度坐標的表格中。啟用插件後,現有數據將被索引,以及以後的任何數據。
使用方法:
在啟用前,使用“sc_geodatastore_meta_keys”篩選器設定要捕獲的meta鍵。你的緯度和經度值必須存儲在單個的meta字段中,例如:51.507334,-0.127682
篩選器的示例用法:
add_filter( 'sc_geodatastore_meta_keys', 'homes_for_sale_geodata' );
function homes_for_sale_geodata( $keys )
{
$keys[] = "properties_address_coords";
return $keys;
}
注意:
此插件目前僅限於允許每個文章只有一對坐標。也許在以後的版本中,我會允許每個文章有多對坐標,但由於此插件是為了我自己的目的而製作的,它已經很好用了,我還沒有必要進一步完善它。
外掛標籤
開發者團隊
原文外掛簡介
This plugin is meant to be used by other developers and to be used together with themes and other plugins. Many themes and plugins use WordPress meta data table to store longitude and latitude co-ordinates for posts. While this works fine the meta data table cannot be indexed very well. Let’s take for example you have made a custom post type called ‘properties’. You create 100,000 posts all attached with latitude and longitude co-ordinates. You want your users to search for those properties in a 50 mile radius for example. Because of the method of which WordPress stores the meta data the query is slow especially when dealing with large amounts of data.
This plugin has been made to retro fit your current WordPress install. You as the developer select, using filters, what meta data you want to start capturing and this plugin will put the data in a table better optimized for storing latitude and longitude co-ordinates. Upon plugin activate existing data will be index and any data from then on.
Usage:
Before activating set what meta keys you want this plugin to capture by using the filter ‘sc_geodatastore_meta_keys’. Your latitude and longitude values have to be stored in a single meta field like: 51.507334,-0.127682
Example usage of the filter:
add_filter( 'sc_geodatastore_meta_keys', 'homes_for_sale_geodata' );
function homes_for_sale_geodata( $keys )
{
$keys[] = "properties_address_coords";
return $keys;
}
Notice:
This plugin is currently limited to only allowing one pair of co-ordinates per post. Maybe in a later version I will allow multiple pairs per post, but since this plugin was made to serve my purpose and it serves it well I see no reason to build upon it yet.
