內容簡介
本外掛程式機能正在積極開發中!
使用自訂欄位值擴充您網站的查詢和排序功能。
以下函數將註冊可查詢欄位。
register_custom_queryable_field($fieldName, $options);
簡單的範例:
register_custom_queryable_field(‘city’);
(以上註冊了自訂欄位‘city’以使用查詢變數進行搜尋)
http://www.yoursite.com/?city=Anahiem
(顯示擁有元鍵‘city’及其值為‘Anahiem’的文章)
進階範例:
register_custom_queryable_field(“price”, array(“dataType”=>”numeric”));
(以上註冊了自訂欄位“price”,以使用查詢變數進行數字搜尋)
http://www.yoursite.com/?price=500
(顯示擁有元鍵‘price’及其值為‘500’的文章)
http://www.yoursite.com/?price_min=200&price_max=800&order_by=price
(顯示文章,以‘price’為排序依據,其自訂欄位‘price’的值為‘200’至‘800’之間)
可用選項:
dataType
text(預設)
numeric(接收min / max查詢變數,見上述範例)
order
如果使用者使用“order_by”查詢變數,則此選項決定排序方式。可用的選項為ASC和DESC(預設)
compare
文字類型的比較方法。預設為‘=’。建議使用‘LIKE’
可使用“order_by”查詢變數進行排序。只需在URL中添加&order_by=price即可。在此例中,查詢將基於價格欄位進行排序。
注意:本外掛程式在後端時不會影響任何查詢。
外掛標籤
開發者團隊
📦 歷史版本下載
原文外掛簡介
THIS PLUGIN IS IN HEAVY DEVELOPMENT!
Extend your site’s querying and sorting functionality using custom field values.
The following function registers queryable fields.
register_custom_queryable_field($fieldName, $options);
Simple Example:
register_custom_queryable_field(‘city’);
(The above registers the custom field ‘city’ to be searchable using query variables)
http://www.yoursite.com/?city=Anahiem
(displays posts which have a meta key ‘city’ and a value of ‘Anahiem’)
Advanced Example:
register_custom_queryable_field(“price”, array(“dataType”=>”numeric”));
(The above registers the custom field “price” to be searchable as a number using query variables)
http://www.yoursite.com/?price=500
(displays posts which have a meta key ‘price’ and a exact value of ‘500’)
http://www.yoursite.com/?price_min=200&price_max=800&order_by=price
(displays posts, sorted by ‘price’, which have a meta key ‘price’ and a value between ‘200’ and ‘800’)
Available Options:
dataType
text (default)
numeric (receive min/max query variables, see above example)
order
If the user uses the “order_by” query variable then this option determines the order. Available options are “ASC” and “DESC”(default)
compare
Compare method for text types. Defaults to ‘=’. Recommend ‘LIKE’
There is a “order_by” query var made available. This is used by adding &order_by=price to the URL. In this instance, the query would sort based on the “price” field only.
Note: This plugin does not alter any queries when in the backend.
