[wordpress插件] Custom Query Fields自定义查询字段

wordpress 插件 文章 2020-04-09 11:50 584 0 全屏看文

AI助手支持GPT4.0

评分
0
描述

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);

register_custom_queryable_field($ fieldName,$ options);

Simple Example:
    

简单示例:
    

register_custom_queryable_field(‘city’);

register_custom_queryable_field('city');

(The above registers the custom field ‘city’ to be searchable using query variables)
    

(上面注册了自定义字段“城市”,可使用查询变量进行搜索)
    

http://www.yoursite.com/?city=Anahiem

http://www.yoursite.com/?city=Anahiem

(displays posts which have a meta key ‘city’ and a value of ‘Anahiem’)

(显示具有元键“ city”且值为“ Anahiem”的帖子)

Advanced Example:
    

高级示例:
    

register_custom_queryable_field(“price”, array(“dataType”=>”numeric”));

register_custom_queryable_field(“ price”,array(“ dataType” =>“ numeric”));

(The above registers the custom field “price” to be searchable as a number using query variables)
    

(上面将自定义字段“ price”注册为可使用查询变量搜索为数字)
    

http://www.yoursite.com/?price=500

http://www.yoursite.com/?price=500

(displays posts which have a meta key ‘price’ and a exact value of ‘500’)
    

(显示带有元键“价格”且确切值为“ 500”的帖子)
    

http://www.yoursite.com/?price_min=200&price_max=800&order_by=price

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’)

(显示按“价格”排序的帖子,其中包含一个元键“价格”,其值在“ 200”和“ 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.

          • 如果用户使用“ order_by”查询变量,则此选项确定订单。

            Available options are “ASC” and “DESC”(default)

          • 可用选项为“ ASC”和“ DESC”(默认)

        • compare

        • 比较

            • Compare method for text types.

            • 比较文本类型的方法。

              Defaults to ‘=’.

              默认为“ =”。

              Recommend ‘LIKE’

            • 推荐“赞”

          There is a “order_by” query var made available.

          有一个“ order_by”查询变量可用。

          This is used by adding &order_by=price to the URL.

          这是通过将&order_by = price 添加到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.

          注意:当在后端时,此插件不会更改任何查询。

安装步骤

    1. Upload custom-query-fields directory to the /wp-content/plugins/ directory
    2. custom-query-fields 目录上传到 / wp-content / plugins / 目录

    3. Activate the plugin through the ‘Plugins’ menu in WordPress
    4. 通过WordPress中的“插件”菜单激活插件

    5. See Description on how to enable the custom variables.
    6. 请参阅有关如何启用自定义变量的说明。

下载地址
https://downloads.wordpress.org/plugin/custom-query-fields.zip
-EOF-

AI助手支持GPT4.0