{"id":104202,"date":"2019-05-20T05:03:38","date_gmt":"2019-05-20T05:03:38","guid":{"rendered":"https:\/\/wordpress.org\/plugins\/wuxt-headless-wordpress-api-extensions\/"},"modified":"2019-05-20T08:26:45","modified_gmt":"2019-05-20T08:26:45","slug":"wuxt-headless-wp-api-extensions","status":"publish","type":"plugin","link":"https:\/\/lt.wordpress.org\/plugins\/wuxt-headless-wp-api-extensions\/","author":9227752,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.0","stable_tag":"1.0","tested":"5.2.24","requires":"4.7.0","requires_php":"","requires_plugins":"","header_name":"WUXT Headless WordPress API Extensions","header_author":"@danielauener","header_description":"Handy rest api extensions for front-page, menus, slugs, meta-fields and tax-queries, used by WUXT, dockerized WordPress\/NuxtJs development environment. However, ready to use for any headless WordPress application.","assets_banners_color":"","last_updated":"2019-05-20 08:26:45","external_support_url":"","external_repository_url":"","donate_link":"http:\/\/www.danielauener.com\/","header_plugin_uri":"http:\/\/www.danielauener.com\/wordpress-rest-api-extensions-for-going-headless-wp\/","header_author_uri":"http:\/\/www.danielauener.com","rating":0,"author_block_rating":0,"active_installs":50,"downloads":2683,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","changelog"],"tags":[],"upgrade_notice":[],"ratings":[],"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0"],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":"2091235","resolution":"1","location":"plugin"},"screenshot-3.png":{"filename":"screenshot-3.png","revision":"2091235","resolution":"3","location":"plugin"},"screenshot-2.png":{"filename":"screenshot-2.png","revision":"2091235","resolution":"2","location":"plugin"}},"screenshots":{"1":"Posts request extended with meta-fields from ACF and Yoast WordPress SEO","2":"New menu endpoint","3":"New front-page endpoint"},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[171698,141196,23853],"plugin_category":[],"plugin_contributors":[85172],"plugin_business_model":[],"class_list":["post-104202","plugin","type-plugin","status-publish","hentry","plugin_tags-endpoint-extension","plugin_tags-headless","plugin_tags-rest-api","plugin_contributors-danielauener","plugin_committers-danielauener"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/wuxt-headless-wp-api-extensions.svg","icon_2x":false,"generated":true},"screenshots":[{"src":"https:\/\/ps.w.org\/wuxt-headless-wp-api-extensions\/trunk\/screenshot-1.png?rev=2091235","caption":"Posts request extended with meta-fields from ACF and Yoast WordPress SEO"},{"src":"https:\/\/ps.w.org\/wuxt-headless-wp-api-extensions\/trunk\/screenshot-2.png?rev=2091235","caption":"New menu endpoint"},{"src":"https:\/\/ps.w.org\/wuxt-headless-wp-api-extensions\/trunk\/screenshot-3.png?rev=2091235","caption":"New front-page endpoint"}],"raw_content":"<!--section=description-->\n<p>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.\nIt is originally coded for <a href=\"https:\/\/github.com\/northosts\/wuxt\">WUXT<\/a>, 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.<\/p>\n\n<h3>WordPress API Extensions<\/h3>\n\n<ul>\n<li><strong>Frontpage endpoint<\/strong>: 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.<\/li>\n<li><strong>Menu endpoint<\/strong>: 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.<\/li>\n<li><strong>Slug endpoint<\/strong>: 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 &amp; 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.<\/li>\n<li><strong>Taxonomy filter AND extension<\/strong>: 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.<\/li>\n<li><strong>Geo query<\/strong>: If your application has to get posts by geographical proximity, you can use a geo query.<\/li>\n<li><strong>WordPress SEO meta fields<\/strong>: They are included automatically in the <code>meta<\/code> object if the Yoast WordPress SEO plugin is activated.<\/li>\n<li><strong>Advanced custom fields<\/strong> are included automatically in the <code>meta<\/code> object if the plugin is activated.<\/li>\n<\/ul>\n\n<h3>Endpoints and parameters<\/h3>\n\n<p><strong>Frontpage<\/strong><\/p>\n\n<ul>\n<li><code>GET<\/code> <code>\/wp-json\/wuxt\/v1\/front-page<\/code><\/li>\n<li><code>GET<\/code> <code>\/wp-json\/wuxt\/v1\/front-page?_embed<\/code><\/li>\n<\/ul>\n\n<p><strong>Menu<\/strong><\/p>\n\n<ul>\n<li><code>GET<\/code> <code>\/wp-json\/wuxt\/v1\/menu<\/code><\/li>\n<li><code>GET<\/code> <code>\/wp-json\/wuxt\/v1\/menu?location=&lt;location&gt;<\/code><\/li>\n<\/ul>\n\n<p><strong>Slug<\/strong><\/p>\n\n<ul>\n<li><code>GET<\/code> <code>\/wp-json\/wuxt\/v1\/slug\/&lt;post-or-page-slug&gt;<\/code><\/li>\n<li><code>GET<\/code> <code>\/wp-json\/wuxt\/v1\/slug\/&lt;post-or-page-slug&gt;?_embed<\/code><\/li>\n<\/ul>\n\n<p><strong>Taxonomy filter AND extension<\/strong><\/p>\n\n<ul>\n<li><code>GET<\/code> <code>\/wp-json\/wp\/v2\/posts\/?categories=1,2&amp;and=true<\/code><\/li>\n<\/ul>\n\n<p><strong>GEO query<\/strong><\/p>\n\n<ul>\n<li><code>GET<\/code> <code>\/wp-json\/wp\/v2\/posts\/?coordinates=&lt;lat&gt;,&lt;lng&gt;&amp;distance=&lt;distance&gt;&lt;km|m&gt;<\/code><\/li>\n<li><code>GET<\/code> <code>\/wp-json\/wp\/v2\/posts\/?coordinates=&lt;lat_meta_field&gt;:&lt;lat&gt;,&lt;lng_meta_field&gt;:&lt;lng&gt;&amp;distance=&lt;distance&gt;&lt;km|m&gt;<\/code><\/li>\n<li><code>GET<\/code> <code>\/wp-json\/wp\/v2\/posts\/?coordinates=52.585,13.373&amp;distance=10<\/code><\/li>\n<li><code>GET<\/code> <code>\/wp-json\/wp\/v2\/posts\/?coordinates=lat_mkey:52.585,lng_mkey:13.373&amp;distance=10<\/code><\/li>\n<li><code>GET<\/code> <code>\/wp-json\/wp\/v2\/posts\/?coordinates=52.585,13.373&amp;distance=10m<\/code><\/li>\n<\/ul>\n\n<h3>Links<\/h3>\n\n<ul>\n<li><a href=\"https:\/\/www.danielauener.com\/wordpress-rest-api-extensions-for-going-headless-wp\/\">More detailed end-point description<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/northosts\/wuxt\">WUXT<\/a><\/li>\n<li><a href=\"https:\/\/www.danielauener.com\/nuxt-js-wordpress-wuxt\/\">WUXT release blog post<\/a><\/li>\n<li><a href=\"https:\/\/nuxtjs.org\/\">NuxtJs<\/a><\/li>\n<\/ul>\n\n<h3>Credits<\/h3>\n\n<ul>\n<li>Michael Cox <a href=\"https:\/\/gist.github.com\/michaeland\/191ce08d22fed74da05a\">Menu Class for returning a menu as array<\/a><\/li>\n<\/ul>\n\n<!--section=installation-->\n<ol>\n<li>Upload the <code>wuxt-headless-wp-api-extensions<\/code> folder to the <code>\/wp-content\/plugins\/<\/code> directory<\/li>\n<li>Activate the plugin through the 'Plugins' menu in WordPress<\/li>\n<li>Use the new endpoints<\/li>\n<li>done<\/li>\n<\/ol>\n\n<!--section=changelog-->\n<h4>1.0<\/h4>\n\n<ul>\n<li>Version 1.0 done<\/li>\n<\/ul>","raw_excerpt":"Extensions for the Rest API to provide endpoints that support a more convenient use of headless WordPress as back-end CMS.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/lt.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/104202","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lt.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/lt.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/lt.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=104202"}],"author":[{"embeddable":true,"href":"https:\/\/lt.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/danielauener"}],"wp:attachment":[{"href":"https:\/\/lt.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=104202"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/lt.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=104202"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/lt.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=104202"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/lt.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=104202"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/lt.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=104202"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/lt.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=104202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}