wordpress-rest-api

WordPress REST API Custom Endpoint with URL Parameter

 ̄綄美尐妖づ 提交于 2020-05-26 12:54:08
问题 I am trying to create a custom endpoint for the WordPress REST API and pass parameters through the URL. The endpoint currently is: /wp-json/v1/products/81838240219 What I am trying to achieve is an endpoint that looks like this and being able to retrieve the identifier parameter in the callback. /wp-json/v1/products?identifier=81838240219 // Custom api endpoint test function my_awesome_func( $data ) { $identifier = get_query_var( 'identifier' ); return $identifier; } add_action( 'rest_api

Wordpress REST API - Write to JSON File?

三世轮回 提交于 2020-05-16 05:13:46
问题 I've been messing around with the Wordpress REST API, and created my custom endpoint, and getting the exact data I want. Basically I created an endpoint to receive all my post/pages/acf - Instead of calling the API on each page load, I just wanted to call the API once during my preloader. However, when I call the API, all the logic runs, which then causes a loading time of 1 to 2 seconds. Is there a possibility that whenever I make an update on Wordpress, it will call my endpoint, and write a

Wordpress REST API - Write to JSON File?

此生再无相见时 提交于 2020-05-16 05:10:48
问题 I've been messing around with the Wordpress REST API, and created my custom endpoint, and getting the exact data I want. Basically I created an endpoint to receive all my post/pages/acf - Instead of calling the API on each page load, I just wanted to call the API once during my preloader. However, when I call the API, all the logic runs, which then causes a loading time of 1 to 2 seconds. Is there a possibility that whenever I make an update on Wordpress, it will call my endpoint, and write a

How can I set the index page of my Gatsby site to be one of the dynamically generated pages?

跟風遠走 提交于 2020-02-25 05:05:32
问题 I have a Gatsby site that queries information from a Wordpress REST API with GraphQL to dynamically create the site pages. I'd like to set my index page to be the homepage that is being created dynamically i.e home.html I saw this post that was similar On Gatsby CMS how can i set the about page as a index page However, they have an about.js file that corresponds to their about page, meaning they can export it as a component and use it in index or they can even just copy the contents of that

How to expose all the ACF fields to Wordpress REST API in both pages and custom postypes

与世无争的帅哥 提交于 2020-02-19 07:00:52
问题 I want to expose all the ACF fields that belong to a page or custom post type to the WordPress REST API in order to do some API calls through javascript. The final expected result would be all the ACF fields inside an ACF object that you can easily access. 回答1: Through the following code, you will be able to expose page and your custom postypes ACF fields in the wordpress REST API and access them inside the ACF object. You can obviously customise the postypes to exclude or to include in the

How to expose all the ACF fields to Wordpress REST API in both pages and custom postypes

别来无恙 提交于 2020-02-19 07:00:48
问题 I want to expose all the ACF fields that belong to a page or custom post type to the WordPress REST API in order to do some API calls through javascript. The final expected result would be all the ACF fields inside an ACF object that you can easily access. 回答1: Through the following code, you will be able to expose page and your custom postypes ACF fields in the wordpress REST API and access them inside the ACF object. You can obviously customise the postypes to exclude or to include in the

Wp Rest Api Custom End point

天大地大妈咪最大 提交于 2020-01-30 05:09:57
问题 Im trying to add a custom end point to my wp-rest api the latest version. I have this already but the one with the slug param at the end does not work.. Does any one know why.. would be great if anyone could help.. register_rest_route( 'wp/v2', '/guestmix', array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_guestmixes' ) ), 'schema' => array( $this, 'get_public_item_schema' ) ) ); register_rest_route( 'wp/v2', '/guestmix/(?P<slug>\d+)', array( 'methods' =>

Query WordPress (REST) posts by the order they appear on the admin

假装没事ソ 提交于 2020-01-26 00:44:49
问题 I am using the Post Types Order plugin to re-order posts on WP Admin. Is there a way to fetch WP REST API by that order? /wp-json/wp/v2/posts?orderby ?? WP Rest Api docs only shows order by: date, id, include, title, slug 回答1: Just omit orderby from the query and it will do it: /wp-json/wp/v2/posts?per_page=20&page=1 来源: https://stackoverflow.com/questions/38100699/query-wordpress-rest-posts-by-the-order-they-appear-on-the-admin

Query WordPress (REST) posts by the order they appear on the admin

心已入冬 提交于 2020-01-26 00:44:22
问题 I am using the Post Types Order plugin to re-order posts on WP Admin. Is there a way to fetch WP REST API by that order? /wp-json/wp/v2/posts?orderby ?? WP Rest Api docs only shows order by: date, id, include, title, slug 回答1: Just omit orderby from the query and it will do it: /wp-json/wp/v2/posts?per_page=20&page=1 来源: https://stackoverflow.com/questions/38100699/query-wordpress-rest-posts-by-the-order-they-appear-on-the-admin

Wordpress REST API for user sign up (registration)

你说的曾经没有我的故事 提交于 2020-01-13 06:55:26
问题 Is it possible to create a sign up form that can work through WP REST API for visitors to be able to create accounts on my site? I can create such a form and use it to create new users. This works with wp_rest nonce when I am logged in as administrator. But if there is a visitor which is not logged in, the same form does not work of course. I think this is a question of authentication. Can you suggest a general idea how this can work? How can I allow visitors to be able to sign up with REST