The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [rest-api]

Questions about the core RESTful HTTP API for accessing WP content and data.

Filter by
Sorted by
Tagged with
1
vote
2answers
381 views

Remove caching from wp_remote_get calls from custom plugin

I wrote a plugin to hit an API and display results on a page. When I was testing, every time I hit "preview", the plugin would hit the API and retrieve the most recent data. Now that the plugin is ...
1
vote
0answers
34 views

How to prepare WordPress Rest data for Preview Changes?

I am currently building a custom theme by using WordPress Rest API, ACF and Vuejs. I am able to delete some data for published pages/posts using rest_prepare_page filter and rest_prepare_post filter....
5
votes
1answer
956 views

cURL 28 error after switch from to brew php 7.2 on localhost

I've been running into trouble with all my localhost install of Wordpress reporting cURL error 28 (timeout) since (I believe!)I've switched my PHP version from 7.0 to 7.2 with brew on my local Mac OS ...
0
votes
0answers
17 views

How can I do a search query on on the url from the WordPress JSON API to filter by a subfield?

I have a response consisting of many fields, I customized my endpoint to retrieve the tag_list array that contains details about all the tags associated with a post, including the name, like this: ...
1
vote
1answer
646 views

rest_api_init is run on every rest call to endpoint

I noticed that every time I make a call to a rest endpoint, the register_rest_route method was called. I made the following very simple plugin to make sure that I was not the culprit, but it has the ...
0
votes
1answer
191 views

Plugin Sidebar is not Saving Meta Attribute to Post/Page after “Update”

I have modified the tutorial at https://wordpress.org/gutenberg/handbook/designers-developers/developers/tutorials/plugin-sidebar-0/ to meet ES6+ but I am having trouble getting it to actually save to ...
0
votes
1answer
360 views

Save/update post_meta with Gutenberg from the panel

I've created a block, and I need to save as post_meta a value from an action on the panel. Php side: add_action( 'init', 'yasr_gutenberg_show_in_rest_overall_meta' ); function ...
0
votes
0answers
78 views

wordpressPCL user meta

I'm using the wordpressPCL library to create new users. I need to insert Meta fields as well, how should I structure this field? private static async Task InserUser() { ...
0
votes
0answers
51 views

WP Rest API Get X posts each categories with only using 1 endpoint

I want to display all categories including 3 posts each of it, so will be like this Cat_A -post_1 -post_2 -post_3 Cat_B -post_1 -post_2 -post_3 etc is it possible to get an example of 3 posts from ...
0
votes
0answers
152 views

Callback to custom field is not working in Wordpress REST API

I'm pretty new to the REST API so please excuse any stupid questions. I'm currently trying to develop a plugin and therefore I need to register a custom post type including a custom field. This is all ...
0
votes
1answer
440 views

JWT on Woocommerce cannot work with “Customer” role user

I developing mobile apps, that connect directly to woocommerce rest api. I use this plugin for authenticating, like registering, login, make an order, etc. So the issue come, when I register new user ...
0
votes
0answers
30 views

Retrieving custom Taxonomies terms names in WP REST API

I looking for a way to retrieve all of the taxonomies terms names from a CPT with a single REST call, //mydomain.org/en/wp-json/wp/v2/myCPT?per_page=50&status=publish&_embed'); I can see ...
0
votes
1answer
30 views

Reading POST over admin-ajax.php

Im trying read form POST values submitted over ajax call (admin-ajax.php).The POST is prepared and submitted. Here are the server side action hooks I have in Child Theme's functions.php add_action('...
0
votes
1answer
188 views

Add ajax load more function using WP API

I want to create a load more function using ajax for a post category. I've followed this article on how to proceed, but after I add the function to register the endpoint, it will give me a 404 error ...
2
votes
3answers
559 views

Display sub-taxonomies based on SELECTED parent-taxonomy

I have two drop downs. The first one contains list of parent taxonomies from a custom post type. And the second one contains all the sub-taxonomies at a time. But I'm trying to display only those sub-...
0
votes
0answers
796 views

Autotrader API Integration

I am looking to pull in a feed of used cars from Autotrader. Has anyone had any luck with the Autotrader API Docs and integrating with WordPress? Their current API documentation is very vague - is ...
0
votes
0answers
25 views

Attachment metadata has value of '1'

While accessing /wp-json/wp/v2/media endpoint I'd got an error 500. Checking the logs, I'd seen the following issue: PHP Recoverable fatal error: Object of class stdClass could not be converted to ...
1
vote
0answers
41 views

Extending wp JavaScript base class to make a post request to a custom REST endpoint

I've defined a REST endpoint /my-plugin/v1/post-read to show whether a post has been read or not, per-user. In PHP, my plugin keeps track of this depending on page views while logged in. I'm now ...
0
votes
1answer
1k views

How to use Python to create a Post in Wordpress?

I found the API reference here: https://v2.wp-api.org/reference/posts/ Based on the API reference above, I wrote this Python code: from urllib.request import Request, urlopen from datetime import ...
0
votes
0answers
36 views

Relations between taxonomy terms for getting parent child nested Json objects and arrays

i have 2 taxonomies (cat) (subcat) and they have some terms(rows) for example , , i want make a relation like SQL data tables between the taxonomy terms for giving me a nested object of arrays in the ...
0
votes
1answer
288 views

Woocommerce Rest Api Categories problem

/wp-json/wc/v3/products/categories My site has 10 main categories. But when I run the query, only 3 main categories and their subcategories are listed. Other categories don’t come up with what could ...
0
votes
1answer
541 views

How to render WP Rest-API Endpoints in a React.js Theme with Woocommerce

I am building a Ecommerce Wordpress/Woocommerce Theme using React.js. I am using the npm package: create-react-wptheme This package renders the react app directly inside of the index.php of the ...
0
votes
0answers
24 views

Create new editable route/endpoint based on meta key

I'm currently making a store which is receiving it's data from external sources. Being new to the world of editing/creating REST API, I've come across a problem. The problem is that the external ...
1
vote
1answer
38 views

Notify Jenkins of new post on Wordpress

Does anyone know if it is possible to "notify" a Jenkins VI server whenever a new post is made on a headless wordpress installation? The reason why I'm asking this is because I'm using gatsby to ...
0
votes
2answers
835 views

Update user meta via REST API?

I have a native app project that gets all data from /wp-json/wp/v2. I've registered phone using this register_meta('user', 'phone', array( "type" => "string", "show_in_rest" => true ));...
0
votes
1answer
440 views

Wordpress API for custom post types returns rest_no_route

I created a custom post type and I am trying to get the posts from it using WP-API, however, when I try to access the API I get the error rest_no_route message. The set up for my custom post type is ...
-2
votes
1answer
20 views

Taxonomy term RestApi data 10 rows limitions

i have created a pod taxonomy(Products) in Wordpress ... i have 16 item of terms(categories) for product taxonomy ... but after going to this routes : http://...../wp-json/wp/v2/product_categories , ...
0
votes
1answer
103 views

Access WP_REST_Server from within plugin namespace

I am new to OOP and developing plugins. I have developed a plugin using the Plugin-Boilerplate with namespace. I expanded the boilerplate to include a REST folder and class so I could create custom ...
0
votes
0answers
141 views

Where is the HTML content for my post in the API

I've been looking at the docs and tutorials online to find out if there's a way to get to the html content of my posts. For example, this endpoint gives me all the information related to one post, but ...
0
votes
2answers
94 views

Store post in raw markdown format, no html?

Is it possible to store posts in pure markdown format? so that I can retrieve the content through the REST API and get the markdown code, without any added html?
-1
votes
2answers
44 views

Create a new page on front page for logged in user

I am going to find a way for logged in users to create pages from front page. For example there are three buttons so called button1,2,3. When logged in users clicks on button1, a page with title ...
2
votes
0answers
470 views

Understanding SHORTINIT with Wordpress 5

What I am trying to achieve I am looking at using Wordpress decoupled, and most tutorials and guides go into detail on using the Rest API. Recently, I discovered the SHORTINIT option to load a very ...
0
votes
0answers
76 views

Order REST API by acf date picker

I'm currently working with wordpress API, I need to order my callback from the api by my ACF. Right now my query looks like this: https://odeonodense.dk/wp-json/wp/v2/events I want to order this ...
0
votes
0answers
36 views

create post usin rest API only after user have been registered and logged in via ajax returns 403 cookie nonce is invalid

I have a 3 step form and the last step is register or log in step. If the user is already logged in the third step is not shown to him and after second step the form will generate post using wp rest ...
0
votes
1answer
26 views

How to create callback function which returns all posts with specific data?

I need to create a new route all which returns only the specified fields for all posts. add_action( 'rest_api_init', function () { register_rest_route( 'custom', 'all' ,array( 'methods'...
1
vote
1answer
154 views

Why my admin doesn't work after adding rest_prepare_post filter?

When I add a filter to custom get_all_posts API callback, API works, but the admin page for each page is blank. Why? function get_all_posts( $data, $post, $context ) { return [ 'id' ...
0
votes
0answers
285 views

Upload Media using the WP API

I'm trying to create a plugin to allow me to upload media files to the media library using the WordPress API V2. I'm trying to use Filepond to do this but I'm facing a 401 unauthorized issue. plugin....
0
votes
1answer
57 views

Custom route and query

I am trying to use a custom WordPress route and function, but I am getting a route and function not found error. Below is my code but I am not sure where it is breaking: add_action('rest_api_init', ...
1
vote
1answer
123 views

ACF attachment custom field in rest response

I created an extra select option ACF field for media uploader and I would like to retrieve the associated values in Gutenberg MediaUploader onSelect. Is there a workaround for this case?
0
votes
2answers
145 views

Detect if REST API is running

Many times I have code and I want to make sure it only runs in a rest api context, or it never runs in a rest context. I know there are some hooks, but is there a function similar to wp_is_doing_cron?...
1
vote
1answer
54 views

WordPress 5 WP REST routes - No errors

I'm using WP JSON to return JSON for certain routes. Prior to WordPress 5, WP JSON would return PHP errors in the response, e.g. Notice:xxx or Warning:xxx when a PHP error was encountered. Since I ...
0
votes
1answer
142 views

Using The REST API How To Pull All Custom Posts?

What I am trying to do is pull back all posts of a custom post type. I know with the WordPress REST API you can add per_page=100 to the end of the REST API to pull back 100 posts, but I need a way to ...
0
votes
0answers
384 views

REST API v2: Get List of Posts by Multple Taxonomy Tags using AND Operator

I'm currently working on an Angular application that interfaces with Wordpress' REST api. A major component of this application is a filterable index of Posts where users can select multiple tags to ...
0
votes
0answers
21 views

Get value of HAL links of post fetched from WordPress REST API

I'm fetching a list of posts from the WordPress Rest API and receive them fine. After receiving them I want to display/work with the links passed by the API at the End of the response. The links are ...
0
votes
1answer
248 views

Serve text/html from wp-json API via WPEngine, headers not being set properly

I have read multiple entries in the WP Codex, numerous articles and Stack Exchange questions. I have a fully functioning API for a private plugin I am developing, but when moving it into production on ...
0
votes
0answers
84 views

Woocommerce REST API for my account & checkout process

I'm new in WooCommerce REST API, I have worked with custom endpoints but I need some help/tutorial related to WooCommerce REST API. I have research about it but I didn't found any tutorial(s) for this....
0
votes
0answers
357 views

Custom meta POST request fired twice when updating a post in Gutenberg

I have made a feature similar in behaviour to Revision Notes, but for Gutenberg. It is a Gutenberg sidebar plugin which adds a text field where users can write an edit summary when they edit a post, ...
0
votes
0answers
27 views

get all event tickets rest api

i'm using ticketra as a plugin and i have donig so will untill i want to get all event's tickets by event id, here is the json response of tickets custom post type: { "id": 159, "date": "2019-01-...
0
votes
2answers
36 views

Why does AWStats show /wp-json* as Viewed URLs

Generally, I track site resource usage using Google Analytics. Recently, I needed to check a clients site stats through AWStats instead. I noticed a number of URLs starting with /wp-json ... My ...
0
votes
0answers
67 views

Wordpress Update Role using API Cross site

I want to get user by email address. Getting issue with custom api endpoint route. function getUserByEmail( $data ) { $user = get_user_by( 'email', $data['email'] ); if ( empty( $...