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, 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
metaobject if the Yoast WordPress SEO plugin is activated.
- Advanced custom fields are included automatically in the
metaobject if the plugin is activated.
Endpoints and parameters
Taxonomy filter AND extension
- Michael Cox Menu Class for returning a menu as array
- Upload the
wuxt-headless-wp-api-extensionsfolder to the
- Activate the plugin through the ‘Plugins’ menu in WordPress
- Use the new endpoints
Er zijn geen beoordelingen voor deze plugin.
Bijdragers & ontwikkelaars
“WUXT Headless WordPress API Extensions” is open source software. De volgende personen hebben bijgedragen aan deze plugin.Bijdragers
Interesse in ontwikkeling?
- Version 1.0 done