[wordpress插件] Advanced Custom Routes – Custom Endpoints for WP REST API高级自定义路由– WP REST API的自定义端点

wordpress 插件 文章 2020-02-07 13:40 585 0 全屏看文

AI助手支持GPT4.0

评分

0

0

描述

The REST API was a great additional to WordPress that made it easy to grab data through the default routes.

REST API是WordPress的一个重要补充,它使通过默认路由轻松获取数据变得容易。

The biggest issue with these default routes is it will either grab too much data or too little data and it didn’t make it easy to only grab the data you need.

这些默认路由的最大问题是,它要么捕获太多数据,要么捕获的数据太少,并且使仅获取所需数据变得不容易。

This plugin makes it possible to create custom routes where you can set to pull only the data you need/want.

这个插件使创建自定义路由成为可能,您可以在其中设置以仅提取需要/想要的数据。

Even better you won’t even have to touch a line of code to make it work, everything will be configurable within the WordPress dashboard.

甚至更好的是,您甚至不必触摸一行代码即可使其工作,所有内容都可以在WordPress仪表板中进行配置。

Features ⚡️

特征⚡️

    • Unlimited custom routes
    • 无限的自定义路线

    • Custom route naming
    • 自定义路线命名

    • Custom filtering to only receive data you need
    • 自定义过滤以仅接收您需要的数据

    • Select which fields to output
    • 选择要输出的字段

    • Query parameters
    • 查询参数

    • A hassle-free experience
    • 无忧的体验

    How to use

    使用方法

      1. To start using Advanced Custom Routes, go to the WordPress dashboard and select the Custom Routes section.
      2. 要开始使用高级自定义路由,请转到WordPress信息中心,然后选择自定义路由部分。

      3. Next click ‘Add New’ to create your first custom route.
      4. 接下来单击“添加新”以创建您的第一个自定义路线。

      5. Give your custom route a name and start configuring your custom route to what you need.
      6. 为您的自定义路线命名,然后开始根据需要配置自定义路线。

      7. Query Builder Options: Select how to filter the posts you would like to receive at this custom route.
      8. 查询生成器选项::选择如何过滤要在此自定义路线上接收的帖子。

      9. Response Output: Select which fields you would like to receive at this custom route.
      10. 响应输出::选择要在此自定义路线上接收的字段。

      11. Once you have configured everything to your liking, publish the custom route and you will now be able to receive your selected data at this route.
      12. 您已根据自己的喜好配置了所有内容,然后发布自定义路线,现在就可以在此路线上接收所选数据。

      Query Builder Options

      查询生成器选项

        • Posts, Pages, and Custom Post Types
        • 帖子,页面和自定义帖子类型

        • Post ID
        • 帖子ID

        • Categories
        • 类别

        • Tags
        • 标签

        • Author
        • 作者

        • Post Parent
        • 邮寄父母

        • Status
        • 状态

        • Order & Orderby
        • 订购和订购者

        • Date
        • 日期

        • Amount & Offset
        • 金额和抵销

        Response Output

        响应输出

          • ID
          • ID

          • Title
          • 标题

          • Content
          • 内容

          • Excerpt
          • 摘录

          • Link
          • 链接

          • Slug
          • 插头

          • Date Posted
          • 发布日期

          • Status
          • 状态

          • Featured Image
          • 精选图片

          • Categories
          • 类别

          • Tags
          • 标签

          • Author
          • 作者

          • Post Type
          • 帖子类型

          • Template
          • 模板

          • Post Parent
          • 邮寄父母

          • Menu Order
          • 菜单顺序

          • Custom Fields
          • 自定义字段

          Route Parameters

          路由参数

          You can also filter your custom routes using query parameters that you add to the end of your custom route like so:

          您还可以使用添加到自定义路由末尾的查询参数来过滤自定义路由,如下所示:

          https://example.com/wp-json/custom-routes/v1/posts?id=1

            https://example.com/wp-json/custom-routes/v1/posts?id=1

          In the example above it would only pull data for that custom route where the post’s ID was equal to 1. This can be used for multiple different query parameters:

          在上面的示例中,它只会提取帖子ID等于1的自定义路线的数据。这可用于多个不同的查询参数:

            • amount
            • 金额

            • offset
            • 偏移量

            • page
            • 页面

            • post_type
            • post_type

            • id
            • id

            • id_exclude
            • id_exclude

            • category
            • 类别

            • category_exclude
            • category_exclude

            • tag
            • 标签

            • tag_exclude
            • tag_exclude

            • author
            • 作者

            • author_exclude
            • author_exclude

            • post_parent
            • post_parent

            • post_parent_exclude
            • post_parent_exclude

            • status
            • 状态

            • date_before
            • date_before

            • date_after
            • date_after

            • order
            • 订购

            • orderby
            • orderby

            • slug
            • sl

            • search
            • 搜索

            • page
            • 页面

            Single Post Route

            单发布路线

            You can also receive data for a single post at a custom route using either an ID or a Slug, like so:

            您还可以使用ID或Slug在自定义路线上接收单个帖子的数据,如下所示:

            ID:

            ID:

            https://example.com/wp-json/custom-routes/v1/posts/1

              https://example.com/wp-json/custom-routes/v1/posts/1

            (This would grab the post with an ID of 1 at this custom route)

            (这将在此自定义路线上获取ID为1的帖子)

            Slug:

            插头:

            https://example.com/wp-json/custom-routes/v1/posts/hello-world

              https://example.com/wp-json/custom-routes/v1/posts/hello-world

            (This would grab the post with the slug of hello-world at this custom route)

            (这会在此自定义路线上以 hello-world 的标语抓住帖子)

            How to install Advanced Custom Routes.

            如何安装高级自定义路由。

            Using WordPress Plugin Directory

            使用WordPress插件目录

            Navigate to the ‘Add New’ in the plugins dashboard

            导航至插件仪表板中的“添加新项”

            Search for ‘Advanced Custom Routes’

            搜索“高级自定义路线”

            Click ‘Install Now’

            点击“立即安装”

            Activate the plugin on the Plugin dashboard

            在“插件”仪表板上激活插件

            Uploading it to WordPress

            将其上传到WordPress

            Navigate to the ‘Add New’ in the plugins dashboard

            导航至插件仪表板中的“添加新项”

            Navigate to the ‘Upload’ area

            导航到“上传”区域

            Select advanced-custom-routes.zip from your computer

            从计算机中选择advanced-custom-routes.zip

            Click ‘Install Now’

            点击“立即安装”

            Activate the plugin in the Plugin dashboard

            在“插件”信息中心中激活插件

            Via FTP

            通过FTP

            Download advanced-custom-routes.zip

            下载advanced-custom-routes.zip

            Extract the advanced-custom-routes directory to your computer

            将advanced-custom-routes目录提取到您的计算机中

            Upload the advanced-custom-routes directory to the /wp-content/plugins/ directory

            将advanced-custom-routes目录上载到/ wp-content / plugins /目录

            Activate the plugin in the Plugin dashboard

            在“插件”信息中心中激活插件

下载地址

https://downloads.wordpress.org/plugin/advanced-custom-routes-custom-endpoints-for-wp-rest-api.0.8.0.zip

https://downloads.wordpress.org/plugin/advanced-custom-routes-custom-endpoints-for-wp-rest-api.0.8.0.zip

-EOF-

AI助手支持GPT4.0