Title: WUXT Headless WordPress API Extensions
Author: danielauener
Published: <strong>2019 年 5 月 20 日</strong>
Last modified: 2019 年 5 月 20 日

---

搜索插件

**该插件尚未通过WordPress的最新3个主要版本进行测试**。 当与较新版本的WordPress一起
使用时，可能不再受到维护或支持，并且可能会存在兼容性问题。

![](https://s.w.org/plugins/geopattern-icon/wuxt-headless-wp-api-extensions.svg)

# WUXT Headless WordPress API Extensions

 作者：[danielauener](https://profiles.wordpress.org/danielauener/)

[下载](https://downloads.wordpress.org/plugin/wuxt-headless-wp-api-extensions.1.0.zip)

 * [详情](https://cn.wordpress.org/plugins/wuxt-headless-wp-api-extensions/#description)
 * [评价](https://cn.wordpress.org/plugins/wuxt-headless-wp-api-extensions/#reviews)
 *  [安装](https://cn.wordpress.org/plugins/wuxt-headless-wp-api-extensions/#installation)
 * [开发进展](https://cn.wordpress.org/plugins/wuxt-headless-wp-api-extensions/#developers)

 [支持](https://wordpress.org/support/plugin/wuxt-headless-wp-api-extensions/)

## 描述

This plugin adds a couple of extensions to the WordPress Rest API, which are aimed
to make the use of WordPress as headless CMS easier.
 It is originally coded for
[WUXT](https://github.com/northosts/wuxt), a dockerized development environment 
for headless WordPress combined with NuxtJs. However, it can be used by every other
application, which needs a powerful headless WordPress back-end.

### WordPress API Extensions

 * **Frontpage endpoint**: There is no obvious way to get the WordPress front-page
   via the Rest API. To read the settings, you have to be authorized, which makes
   things unnecessary complicated. The new endpoint returns the front-page object
   if it is set, the ten newest posts otherwise.
 * **Menu endpoint**: Right now, there is no way I know of, for getting menus from
   the API. This endpoint returns an entire menu as nested array. Default location
   is “main”, but you can request other locations.
 * **Slug endpoint**: If you are building a front-end app on top of WordPress, you
   have to think about how to structure your urls. WordPress has two default post-
   types (posts & pages) and in the urls is not distinguished which type you are
   requesting, so http://wp-site.expl/something might lead to a page or a post, 
   dependent on the type of the object with the slug something. If you want to mirror
   that behaviour in your app, you have to do two requests for each url, one searching
   pages, one searching posts. To make that one request, use the slug end-point.
 * **Taxonomy filter AND extension**: When filtering taxonomies with an Rest API
   request, all queries are OR-queries. That means you can get posts which are either
   in category A or B. Our adjustment lets you switch all tax_queries to an AND-
   relation, so that you can select posts which are both in category A and B.
 * **Geo query**: If your application has to get posts by geographical proximity,
   you can use a geo query.
 * **WordPress SEO meta fields**: They are included automatically in the `meta` 
   object if the Yoast WordPress SEO plugin is activated.
 * **Advanced custom fields** are included automatically in the `meta` object if
   the plugin is activated.

### Endpoints and parameters

**Frontpage**

 * `GET` `/wp-json/wuxt/v1/front-page`
 * `GET` `/wp-json/wuxt/v1/front-page?_embed`

**Menu**

 * `GET` `/wp-json/wuxt/v1/menu`
 * `GET` `/wp-json/wuxt/v1/menu?location=<location>`

**Slug**

 * `GET` `/wp-json/wuxt/v1/slug/<post-or-page-slug>`
 * `GET` `/wp-json/wuxt/v1/slug/<post-or-page-slug>?_embed`

**Taxonomy filter AND extension**

 * `GET` `/wp-json/wp/v2/posts/?categories=1,2&and=true`

**GEO query**

 * `GET` `/wp-json/wp/v2/posts/?coordinates=<lat>,<lng>&distance=<distance><km|m
   >`
 * `GET` `/wp-json/wp/v2/posts/?coordinates=<lat_meta_field>:<lat>,<lng_meta_field
   >:<lng>&distance=<distance><km|m>`
 * `GET` `/wp-json/wp/v2/posts/?coordinates=52.585,13.373&distance=10`
 * `GET` `/wp-json/wp/v2/posts/?coordinates=lat_mkey:52.585,lng_mkey:13.373&distance
   =10`
 * `GET` `/wp-json/wp/v2/posts/?coordinates=52.585,13.373&distance=10m`

### Links

 * [More detailed end-point description](https://www.danielauener.com/wordpress-rest-api-extensions-for-going-headless-wp/)
 * [WUXT](https://github.com/northosts/wuxt)
 * [WUXT release blog post](https://www.danielauener.com/nuxt-js-wordpress-wuxt/)
 * [NuxtJs](https://nuxtjs.org/)

### Credits

 * Michael Cox [Menu Class for returning a menu as array](https://gist.github.com/michaeland/191ce08d22fed74da05a)

## 屏幕截图

 * [[
 * Posts request extended with meta-fields from ACF and Yoast WordPress SEO
 * [[
 * New menu endpoint
 * [[
 * New front-page endpoint

## 安装

 1. Upload the `wuxt-headless-wp-api-extensions` folder to the `/wp-content/plugins/`
    directory
 2. Activate the plugin through the ‘Plugins’ menu in WordPress
 3. Use the new endpoints
 4. done

## 评价

此插件暂无评价。

## 贡献者及开发者

「WUXT Headless WordPress API Extensions」是开源软件。 以下人员对此插件做出了贡献。

贡献者

 *   [ danielauener ](https://profiles.wordpress.org/danielauener/)

[帮助将「WUXT Headless WordPress API Extensions」翻译成简体中文。](https://translate.wordpress.org/projects/wp-plugins/wuxt-headless-wp-api-extensions)

### 对开发感兴趣吗?

您可以[浏览代码](https://plugins.trac.wordpress.org/browser/wuxt-headless-wp-api-extensions/)，
查看[SVN仓库](https://plugins.svn.wordpress.org/wuxt-headless-wp-api-extensions/)，
或通过[RSS](https://plugins.trac.wordpress.org/log/wuxt-headless-wp-api-extensions/?limit=100&mode=stop_on_copy&format=rss)
订阅[开发日志](https://plugins.trac.wordpress.org/log/wuxt-headless-wp-api-extensions/)。

## 更新日志

#### 1.0

 * Version 1.0 done

## 额外信息

 *  版本 **1.0**
 *  最后更新：**7 年前**
 *  活跃安装数量 **40+**
 *  WordPress 版本 ** 4.7.0 或更高版本 **
 *  已测试的最高版本为 **5.2.24**
 *  语言
 * [English (US)](https://wordpress.org/plugins/wuxt-headless-wp-api-extensions/)
 * 标签
 * [headless](https://cn.wordpress.org/plugins/tags/headless/)[rest-api](https://cn.wordpress.org/plugins/tags/rest-api/)
 *  [高级视图](https://cn.wordpress.org/plugins/wuxt-headless-wp-api-extensions/advanced/)

## 评级

尚未提交反馈。

[Your review](https://wordpress.org/support/plugin/wuxt-headless-wp-api-extensions/reviews/#new-post)

[查看全部评论](https://wordpress.org/support/plugin/wuxt-headless-wp-api-extensions/reviews/)

## 贡献者

 *   [ danielauener ](https://profiles.wordpress.org/danielauener/)

## 支持

有话要说吗？是否需要帮助？

 [查看支持论坛](https://wordpress.org/support/plugin/wuxt-headless-wp-api-extensions/)

## 捐助

您愿意支持这个插件的发展吗?

 [ 捐助此插件 ](http://www.danielauener.com/)