Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [rest-api]

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

0
votes
0answers
10 views

“error_message”: “Sorry, you cannot list resources.” using WooCommerce API

When requesting the test API, getting the following response: { "errors": [ { "error_code": "", "error_message": "Sorry, you cannot list resources." } ]...
0
votes
0answers
16 views

How to prevent post update using transition_post_status

I am building an application using WP REST API. Ideally, users are able to post only if they have a subscription. Here is how I plan to make things work: Set expire_by user meta when they sign up. ...
0
votes
0answers
10 views

Remove comma in wp-json results

I am using the Wp REST API to filter posts using AJAX. The problem is that when the posts are filtered, a comma is added between them but I am not sure where is it comming from. Here is the code I am ...
0
votes
1answer
9 views

How to get data from a private API and add it to wordpress pages

I got a private API (Cliniko) I want for example the full list of clients to be listed where I want on a page. I know how APIs work, what I don't know is how to implement them in Wordpress. Is there ...
1
vote
1answer
11 views

Add Products to user's ID Woocommerce

I have made an REST API for synchronize user's cart item to web view to android view. I have used CoCart WP plugin Here are some scenarios: If I adding product from website I can get user's cart ...
-1
votes
0answers
9 views

What libraries are available to connect a Python web app to communicate with WordPress via the REST API?

I have a python web app, and I would like to connect it to WordPress via the REST API. The app will need to communicate in two directions (i.e. the app will both need to send and receive information ...
0
votes
1answer
25 views

Can I define multiple callback methods depending on the call method?

He is my current custom API: add_action( 'rest_api_init', function () { register_rest_route('my-project/v1/form', '/get', array( 'methods' => WP_REST_Server::READABLE, 'callback' => '...
0
votes
0answers
14 views

How to apply 'rest_post_query' filter only when fetching a single post?

I'm working with the Wordpress API. I have modified the default query using rest_post_query to exclude a certain category: add_filter( 'rest_post_query', 'get_posts', 10, 2 ); function get_posts( $...
1
vote
1answer
17 views

Is there a way to identify a user in a custom REST API method?

In a custom REST API method, I would like to identify the user (typically get_current_user_id() then retrieve their data from database (things like they're role and some custom permission). But so ...
5
votes
2answers
541 views

Why is my custom API endpoint not working?

I tried to include this code in my plug-in php files as well as in functions.php. (In the end I would like it to be in the plug-in's php file but I'm not yet sure if possible, that would probably be ...
0
votes
0answers
19 views

GETing data from a gzip compressed API?

I know WP can get JSON API data via a GET request, but does anyone know plugins/ways that I can get and decompress JSON data from a gzip compressed API? I would then output the JSON response to a ...
0
votes
0answers
23 views

Using Wordpress solely as a Backend - dealing with WP_SITEURL

I've built a website in Angular that leverages Wordpress as a backend, specifically using its REST API. I am replacing an existing website, and my client does not intend to change the original ...
0
votes
1answer
27 views

WordPress multisite REST API connection refused with android - redirects to home page when using IP address in Postman

I have built a sub-directory type multisite and installed wp rest api on my localhost. Next step would be to connect the multisite to my android app using the rest api. This is where things go wrong. ...
0
votes
1answer
53 views

How to Authenticate WP REST API with JWT Authentication using Fetch API

My goal is to send user comments with a POST request from a server-side Lambda function to my WordPress API. I'm using Gatsby and Netlify. When someone leaves a comment in the comment form of my ...
1
vote
2answers
105 views

Wordpress Rest filter for custom taxonomy gets applied to the admin area

I have a custom taxonomy called collection, with advanced custom fields in it. I'm using wordpress API, so since I need to filter the API responses by ACF values, I have this filter in my theme ...
-2
votes
0answers
24 views

Gutenberg Block Development - how to start

As WP is moving toward the REACT bases and the Gutenberg is the first step. So can anyone help me out on how to start learning Gutenberg
0
votes
0answers
9 views

auth error with react native and wordpress rest api jwt token

I am trying to user wordpress rest api with jwt token and react native but I have issues debugging with postman; jwt/token returns the token, and the user display, etc. jwt/token/validate returns ...
1
vote
0answers
38 views

How do I add meta when creating a post with rest api?

I have this code that inserts a post into WordPress site using Rest API: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $row->site_url."/wp-json/wp/v2/posts"); curl_setopt($ch, ...
0
votes
1answer
39 views

rest api authentication

So I'm trying to learn the WP Rest API. I want to create a post. I'm using the postman app. I get the 401 error when I try to POST (GET is fine) But I thought being logged onto my WP site would be ...
1
vote
1answer
18 views

Get Block Attributes in JSON REST API

I am trying to make my block attributes show up in the REST API. To start, I've added the rest_api_init hook to whitelist my block for inclusion. add_action( 'rest_api_init', function () { ...
0
votes
0answers
9 views

what make difference between shipping methods for a zone when a create order with woo api

please help ,when i decide to create an order i found that i have to specific shipping_lines "shipping_lines": [ { "method_id": "flat_rate", "method_title": "Flat Rate", "total"...
0
votes
0answers
13 views

Get automatically added content to posts via wo json rest api

I am using advanced ads plugin to show my custom image ads using placements, so these ads get automatically placed within the posts. Now I want use wo json ali in my android app and want to get those ...
0
votes
0answers
21 views

How to set JWT token with PHP on successful login?

I'm creating a decoupled application: the frontend is built with React, the backend uses Wordpress. However, due to some limitations the login and registration frontend pages must use a Wordpress ...
0
votes
0answers
14 views

wrapping 'rest_api_init' in 'is_admin()' function

i'm create custom admin page via add_menu_page, let's imagine that my custom page has url wp-admin/admin.php?page=settings_page then i'm checki is_admin() function via var_dump on my ...
0
votes
0answers
59 views

get token using the 'WordPress REST API with JWT Authentication' plugin

I'm trying to build a Wordpress plugin that is an API which can be queried from remote websites. I want to secure it with JWT web tokens, so I did install the JWT Authentication for WP REST API ...
3
votes
2answers
40 views

When to check for max_num_pages using Wordpress REST API?

I'm implementing infinite loading using the WP API, so I pull in the new posts via an API request. Because the default API response is fine with me and I only really need to filter the posts returned, ...
0
votes
1answer
32 views

How to search by metadata using REST API

I have a custom post type like this: register_post_type('horario_busao', [ 'labels' => [ 'name' => 'Horário Busões', 'singular_name' => 'Horário Busão' ], 'public'...
0
votes
1answer
22 views

PHP: authenticate for a REST request?

I did create some custom endpoints for a plugin i'm working on, with the REST api. It works quite well, but now I would like to secure those requests : I don't want external users (EDIT: I mean remote ...
0
votes
0answers
47 views

REST : how do you handle the rest_no_route error?

i'm playing with the REST api and when doing some REST requests I got sometimes what I want, and sometimes this response generated by rest_ensure_response() : { "code": "rest_no_route", "data"...
0
votes
0answers
19 views

WP API V2 Filtering URL request second tier

I currently have a WP API URL call that looks like https://siteurl/wp-json/wp/v2/knowledge_base?_embed&knowledge_types=8 The JSON code looks like [ { "knowledge_types": 8, } ] How ...
0
votes
0answers
15 views

How to add new term-meta field in get_the_term array?

I am creating an API which is based on for category posts. In taxonomy category there is one ACF field for image upload. In API i am fetching category values like this: $cat_post = new stdClass(); ...
2
votes
1answer
68 views

How to return Meta data from the REST API?

I added meta box City and Location to my post, but when I calling the endpoint (by WP Rest API) /wp-json/wp/v2/<post_type>/<post_id> it's not returning my meta data. I tried to use ...
1
vote
1answer
52 views

Does pre_get_posts affect REST API responses?

I'm trying to limit the content that is returned via REST API routes to only contain content published by the current logged in user. I'm trying to do this using pre_get_posts which works fine when in ...
0
votes
1answer
33 views

Buddypress update user avatar image via REST

I’m creating a custom back-end API to update a user avatar image via user id. So i send via post REST request this parameters: – user_id : The id of the user; – image: base64 image; – image_name: ...
0
votes
1answer
24 views

phpmailer_init ignored on REST calls

For testing purposes I've set up a mailtrap (dummy SMTP server) to catch all mail in and out of my local site. To do so, I hooked its configuration in the theme's functions.php like this: function ...
0
votes
1answer
12 views

Detect permalinks when passing querystring in REST API requests

Let's say I'm using wp_localize_script to pass base REST url to my script in a Wordpress plugin: wp_register_script( 'my-plugin', plugin_dir_url( __FILE__ ) . '../dist/admin-main.js', [], '0.9.2' ); ...
1
vote
1answer
41 views

Unable to get the info of the user which doesn't have created any post via REST API

I am unable to get the user info from the REST API. The user has not any post created. I have installed the Basic-Auth plugin. Whenever I try to get the user info, I get the following error. Request :...
2
votes
0answers
72 views

Transition from (classical) serialized custom meta field to (gutenberg) rest enabled meta

I have a custom meta box for saving values from two input fields into a single post meta field. The data is saved serialized in the DB: get_post_meta( $post->ID, '_custom_key', true ) will ...
0
votes
0answers
19 views

woocommerce plugin to query external vendors REST API

All, I am attempting to assist a friend with some research as to how much it efford /cost it would take to start a woocommerce site to sell ATV/Motorcycle parts and accessories. The site would be ...
1
vote
0answers
14 views

Setting/unsetting terms using the Backbone JavaScript client

I'd like to set and delete terms in my custom taxonomy using the WordPress Backbone JavaScript client, which provides access to the REST API in JavaScript. I can't find an example or suggestion in ...
1
vote
2answers
59 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
16 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....
4
votes
1answer
216 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
7 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: ...
0
votes
1answer
79 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
36 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
63 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
24 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
23 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
38 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 ...