{"id":47925,"date":"2011-05-08T08:00:00","date_gmt":"2011-05-08T08:00:00","guid":{"rendered":"https:\/\/www.weixiaoduo.com\/plugins\/2024\/02\/22\/custom-query-fields\/"},"modified":"2011-05-11T02:03:00","modified_gmt":"2011-05-11T02:03:00","slug":"custom-query-fields","status":"publish","type":"post","link":"https:\/\/www.weixiaoduo.com\/plugins\/custom-query-fields\/","title":{"rendered":"Custom Query Fields"},"content":{"rendered":"<p>THIS PLUGIN IS IN HEAVY DEVELOPMENT!<\/p>\n<p>Extend your site\u2019s querying and sorting functionality using custom field values.<\/p>\n<p>The following function registers queryable fields.<br \/>\n    register_custom_queryable_field($fieldName, $options);<\/p>\n<p>Simple Example:<br \/>\n    register_custom_queryable_field(\u2018city\u2019);<br \/>\n(The above registers the custom field \u2018city\u2019 to be searchable using query variables)<br \/>\n    http:\/\/www.yoursite.com\/?city=Anahiem<br \/>\n(displays posts which have a meta key \u2018city\u2019 and a value of \u2018Anahiem\u2019)<\/p>\n<p>Advanced Example:<br \/>\n    register_custom_queryable_field(\u201cprice\u201d, array(\u201cdataType\u201d=>\u201dnumeric\u201d));<br \/>\n(The above registers the custom field \u201cprice\u201d to be searchable as a number using query variables)<br \/>\n    http:\/\/www.yoursite.com\/?price=500<br \/>\n(displays posts which have a meta key \u2018price\u2019 and a exact value of \u2018500\u2019)<br \/>\n    http:\/\/www.yoursite.com\/?price_min=200&price_max=800&order_by=price<br \/>\n(displays posts, sorted by \u2018price\u2019, which have a meta key \u2018price\u2019 and a value between \u2018200\u2019 and \u2018800\u2019)<\/p>\n<p>Available Options:<\/p>\n<ul>\n<li>dataType\n<ul>\n<li>text (default)<\/li>\n<li>numeric (receive min\/max query variables, see above example)<\/li>\n<\/ul>\n<\/li>\n<li>order\n<ul>\n<li>If the user uses the \u201corder_by\u201d query variable then this option determines the order. Available options are \u201cASC\u201d and \u201cDESC\u201d(default)<\/li>\n<\/ul>\n<\/li>\n<li>compare\n<ul>\n<li>Compare method for text types. Defaults to \u2018=\u2019. Recommend \u2018LIKE\u2019<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>There is a \u201corder_by\u201d query var made available.  This is used by adding <code>&order_by=price<\/code> to the URL.  In this instance, the query would sort based on the \u201cprice\u201d field only.<\/p>\n<p>Note: This plugin does not alter any queries when in the backend.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Extend your site's querying and sorting functionality using custom field values.<\/p>\n","protected":false},"author":65,"featured_media":229092,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"Custom Query Fields - \u8587\u6653\u6735\u63d2\u4ef6\u76ee\u5f55","description":"Extend your site's querying and sorting functionality using custom field values."},"footnotes":""},"categories":[1],"tags":[1292,15966,1361],"class_list":["post-47925","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-custom-fields","tag-meta_query","tag-query"],"_links":{"self":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/47925","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/comments?post=47925"}],"version-history":[{"count":0,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/47925\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/media\/229092"}],"wp:attachment":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/media?parent=47925"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/categories?post=47925"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/tags?post=47925"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}