[wordpress插件] date_query enablerdate_query启动器

wordpress 插件 文章 2020-04-13 01:40 416 0 全屏看文

AI助手支持GPT4.0

评分
100
描述

WP REST API plugin provides the ability to interact with a WordPress installation through a REST API.

WP REST API 插件提供了通过REST API与WordPress安装进行交互的功能。

When retrieving posts, a use case would be to filter them based on they publish date by before/after a certain date.

检索帖子时,用例是根据帖子的发布日期(在特定日期之前/之后)过滤它们。

In WordPress this can be achieved using the date_query parameter.

在WordPress中,可以使用 date_query 参数来实现。

However, the parameter is not part of the whitelisted parameters of WP REST API.

但是,该参数不是WP REST API列入白名单的参数的一部分。

A workaround is to add it ourselves as discussed here.

一种解决方法是按照此处所述将其自己添加。

This plugin adds the date_query param to the whitelist not modifying the theme of WordPress but by using a very small and simple plugin.

该插件将date_query参数添加到白名单中,而不会修改WordPress的主题,而是使用一个非常小而简单的插件。

This allows to change and upgrade themes freely and still keep the whitelisting of the parameter.

这样一来,就可以自由更改和升级主题,并且仍将参数列入白名单。

After installing WP REST API and this plugin, you should be able to run queries like the below,

在安装WP REST API和此插件之后,您应该能够运行以下查询,

/wp-json/wp/v2/posts?filter[date_query][after]=2016-02-26T12:38:36

  / wp-json / wp / v2 / posts?filter [date_query] [after] = 2016-02-26T12:38:36

/wp-json/wp/v2/posts?filter[date_query][before]=2016-02-27T14:28:15

/ wp-json / wp / v2 / posts?filter [date_query] [之前] = 2016-02-27T14:28:15

安装步骤

    1. Upload the plugin files to the /wp-content/plugins/date_query directory, or install the plugin through the WordPress plugins screen directly.
    2. 将插件文件上传到 / wp-content / plugins / date_query 目录,或直接通过WordPress插件屏幕安装插件。

    3. Activate the plugin through the ‘Plugins’ screen in WordPress
    4. 通过WordPress中的“插件”屏幕激活插件

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

AI助手支持GPT4.0