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
0
votes
0answers
18 views

Wordpress REST API only gets data from primary site

I'm currently trying to display custom posts on one of my multisites, but even though the correct posts show up under wp-json/wp/v2 they dont show up on the actual site, instead it just shows the ...
2
votes
0answers
37 views

Limit REST API output to current logged in user that is also author of the content

https://developer.wordpress.org/rest-api/using-the-rest-api/frequently-asked-questions/#require-authentication-for-all-requests This requires authentication for all reque​sts. add_filter( '...
1
vote
0answers
18 views

Solve cors problem using rest api or ajax

I'm building an app with nuxt using WP as a CMS, so I have this code in my functions.php to allow any origin (temporary) using the rest api and admin-ajax urls function add_cors_http_header(){ // ...
0
votes
0answers
7 views

How to filter customer collection using Rest API v2?

Is there any way to filter customer collection by created or modified date using rest API? I have also check this document. But,there's not available any parameter for that.
0
votes
0answers
13 views

How to logout remotely from other website

My requirement is something like: Let's say I have a client side app/website. There will be logout link and on clicking Logout link, it will also remotely logout wordpress site. I believe WP has a ...
0
votes
1answer
9 views

Wordpress HTTP API NTLM Authentication

I was wondering if anyone has had to use NTLM authentication when using wp_remote_get? Trying to authenticate using Basic but that is returning the proxy error. When I use other authenticators for ...
0
votes
1answer
21 views

Upload User Avatar from android to Wordpress using Rest API

I am developing an android app that give users ability to browse , register, login, post and comment to my wordpress blog using Rest Api . I am trying now to add a way for users to update their ...
0
votes
1answer
17 views

[Zapier + WP Webhooks Pro]: Custom Fields get cut off at first comma or semicolon

I'm using Zapier and WP Webhooks Pro to connect Google Sheet and WP to auto-publish posts for each row added to the spreadsheet. It works like as expected and all fields, including custom fields, ...
-1
votes
0answers
22 views

{SOLVED} How to use REST API to test user login

I have a website A using WordPress with registered users and a website B built with Symfony. I want to grant access to site B, which has a login page, depending on website A. i.e: If I am a ...
0
votes
1answer
15 views

Is There A Plugin to Create WP Multisite Installs programatically

So I created a wordpress multi-site and I want to be able to create multiple sites in the network programmatically. My subscription service has an API so I can create username and passwords on the fly ...
0
votes
1answer
34 views

REST API: No route was found matching the URL and request method

I'm having issues adding a custom REST API route to Wordpress. Using my own plugin, i've registered the route as followed: add_action( 'rest_api_init', function() { register_rest_route( $namespace, ...
0
votes
0answers
8 views

Is there any method to add a Custom Comment Type to WordPress REST API?

Hellow!I am using AnsPress plugin(Forum/Question and answer plugin) with some customization.In Anspress,visitors can post replies to answers.Those replies stores in WordPress database under a comment ...
0
votes
0answers
21 views

“No Access-Control-Allow-Origin header is present” even though it is in the entry file

I'm seeing this in the Chrome browser console after doing a test fetch request: Access to fetch at 'http://localhost/wptest2/wp-json/pluginFolder/1.0/load?limit=10&offset=0' from origin '...
0
votes
0answers
16 views

Wordpress API returns empty page when page is less than X-WP-TotalPages

I am querying in the Wordpress API for all pages of media attachments. I am going page by page. I have about 5800 pages and when I hit pages 50-53 they return a blank or more of a [] but it is a ...
0
votes
0answers
14 views

Advanced analytics tools for WooCommerce?

Premise This question might seem out of topic but in my opinion it's strictly related to the whole Wordpress / WooCommerce ecosystem and its performance optimization. Problem The issue is about ...
0
votes
0answers
26 views

do_action doesn't trigger if it's in a template that gets loaded via REST endpoint

i'm building a single page application using woocommerce and custom REST endpoints to get template parts and load them into the browser ... one endpoint is getting content-single-product.php template ...
0
votes
0answers
10 views

Woocommerce Product don't return custom taxosonomy when using REST api

I created a custom taxonomy for woocommerece product. It's working fine in wordpress. but when I try to fetch it through REST (Javascript), it's missing. All other properties are returning but not ...
0
votes
0answers
18 views

Help when displaying a link in the Woocommerce order table

I am developing a module for woocommerce that consumes an API, in the back it shows the link correctly of each order that is made, but my problem is when I want to insert this link in the part that ...
1
vote
1answer
14 views

How do I get the intended post type of a revision post?

I have a headless Wordpress instance with multiple custom post types. The build takes a few minutes, so I'm building a way to display drafts by fetching the latest revision via an API, like so: $...
1
vote
0answers
21 views

Update a post based on results from GET request to another server

I need to use GET requests to retrieve the current status of a device and then update the body of a specific Wordpress post with the text data sent by the external device (for reference, it will use ...
0
votes
0answers
11 views

Wordpress improve REST API - SHORTINIT not work

i'm trying to improve the performance of Wordpress API custom endpoints. I created a plugin, simple file under plugin/PLUGIN_NAME folder where I call "register_rest_route" function to set the ...
1
vote
0answers
16 views

How to insert Comment metadata via REST API

I am trying to insert comment from my android app , i am using REST API and POST method /wp-json/wp/v2/comments/ The method is working great , but I would like to include metadata when inserting ...
0
votes
2answers
20 views

How to get all post of custom post type by rest api?

I have CPT transcript in wordpress website. And create 250 post in CPT transcript. Now, I want to fetch all transcript data and want to store in another database using rest api url http://example.com/...
0
votes
1answer
15 views

Should I worry about SQL injection when using REST API?

Should I worry about SQL injection when using REST API and sql queries via $wpdb? For example, is the bellow vulnerable to sql injection? public static function get_post( WP_REST_Request $request ) ...
0
votes
0answers
18 views

Create Session with JWT

I'm currently working on a shop like project that uses React as frontend and Wordpress with Woocommerce as a backend. To authenticate with the API I use the JWT Authentication for WP REST API, which ...
1
vote
1answer
28 views

Headless Wordpress: How to authenticate front end requests?

I am envisioning Wordpress on the back end to work with React.js on the front end like this: Wordpress is installed on http://example.com/api React.js script is loaded into http://example.com/index....
2
votes
0answers
101 views

x-wp-nonce is not allowed by Access-Control-Allow-Headers in preflight response

I would like my dev server on http://localhost:8080 to work with my wordpress install's rest api, of which the api base url is at http://localhost/wptest2/index.php/wp-json/ I am currently getting the ...
1
vote
1answer
20 views

Passing a borrowed nonce through Postman fails

I'm trying to test borrowing a nonce from my browser session so that I can use it elsewhere, namely in my npm dev environment. I took a nonce passed into an open Chrome browser session, put it in a ...
1
vote
1answer
41 views

pagination in WP rest api

We have made a custom API to get all the post in descending order and we want to add pagination in that API. I have read other questions and answers but didn't get the idea. Can anyone explain to me ...
0
votes
1answer
38 views

How do I correctly setup an AJAX nonce for WordPress REST API?

Following a link comment here which led me to these docs, I've tried to set up a nonce for user authentication. I added: wp_localize_script( 'wp-api', 'wpApiSettings', array( 'root' => ...
0
votes
1answer
33 views

Does jQuery/Ajax send cookies when using the rest API or do I need to somehow add them?

I've run into an odd situation with user capabilities. I have set up a rest endpoint on my local computer and am the super admin. The rest endpoint is called and the first thing it does is see if ...
0
votes
0answers
36 views

I can't post comment via REST API

I try to insert comment via REST API , but i get this error : Query parameter not permitted: author I followed this docs and author is one of the arguments this is the link test that i use https:/...
0
votes
0answers
65 views

Custom REST API with Stripe webhooks error: No signatures found matching the expected signature for payload

I've created an API endpoint listener for the Stripe "payment successful" webhook on our installation. add_action( 'rest_api_init', function () { register_rest_route( 'myplugin/v1', '/stripe', ...
0
votes
0answers
22 views

Can I set rest API endpoints from within a theme?

I would like to know if it is possible to set rest API endpoints from within a theme? I created a class to do this and made an instance of the class in the theme's functions.php file. This triggers ...
1
vote
0answers
22 views

Woocommerce REST API - updating an order changes custom tax calculations

We have a online woocommerce store that processes two types of orders: shipping and instore pickup. Shipping calculates taxes based on billing address and instore uses the store address (zip). ...
0
votes
1answer
28 views

register_rest_field update_callback don't work for $_FILES

I try to insert a post with REST API who contain text and image in one api call. My image is an acf field. I register my field like that: register_rest_field( 'project', 'logo', array( '...
-1
votes
1answer
19 views

Wordpress API standard compliance and specification for external database [closed]

HOW TO CONNECT WORDPRESS WITH EXTERNAL DB SERVER VIA API?
0
votes
0answers
13 views

How to rerieve comments and their replies from DB

I need to get comments and their replies from database to show them as json for an android app, so how can i tell if a comment has replies (get their number ) , and how can i list replies nested with ...
0
votes
1answer
63 views

Rest API: wp_verify_nonce() fails despite receiving correct nonce value

I am generating a nonce to be used with client side fetch requests to the rest api: function prepAllAdminScripts() { wp_register_script( 'reactAdminArea' , PLUGIN_FOLDER_URL . 'shared/...
0
votes
1answer
70 views

REST API and filtering by meta value

I have a posttype 'timeslip' and I am calling this with the following API endpoint: /wp-json/wp/v2/timeslip?meta_key=user_id&meta_value=1 I have exposed my custom field user_id to the API meta ...
0
votes
1answer
14 views

Is there anyway to format my EndPoint URL in WordPress?

I have wrote an endpoint in WordPress and it works just fine. The problem is with the URL. The current format of the URL request must be like this: https://iotkidsiq.com/wp-json/zaindob/v1/sync_order/...
1
vote
1answer
21 views

WP_Query To call data from diffrent tables

I need to retrieve data from multiple tables , wp_postmeta to get posts with a specific type ( question ) , wp_user for author informations and also wp_comments . I need those information to use them ...
1
vote
1answer
39 views

Return WP_Error as WP_REST_Response

I have a http request to WP REST API that can resolve in a success or a failure status The success gets handled by WP_REST_Response, and if any error occurs this is handled by WP_Error, both returned ...
0
votes
0answers
23 views

WooCommerce - Add product with Product category and Image from Mobile App

I am new to WooCommerce development and REST API provided by WooCommerce. I am facing 2 issues right to add new product as a vendor from my Mobile app which is in React Native. 1.I am adding new ...
0
votes
0answers
56 views

REST API list_user

I need to get a list of users by specific role. I user this endpoint: GET /users?roles=customer but I got: "code": "rest_user_cannot_view", "message": "Sorry, you are not allowed to filter users by ...
2
votes
1answer
22 views

WordPress REST get all items without a taxonomy assigned

i am a bit stuck right now. What i want to achieve is doing a request to the api that returns all posts that do not have a taxonomy assigned. I can do this request to get posts from a specific ...
1
vote
1answer
32 views

current_user_can('administrator') returns false when I'm logged in

protected function isAdmin() : bool { $check = current_user_can('administrator'); return $check; // returns false as I am logged in as superadmin, refreshing the page for xdebug to run }...
0
votes
0answers
24 views

Get templated page/post content via the WordPress API

I've been tasked with converting a WordPress site into a single page application so a persistent audio player can be added, while retaining its current theme. I need to do this in such a way that the ...
0
votes
0answers
25 views

Exclude categories in WP REST API response through function

I want to exclude some categories from the API response but not using the argument exclude but through function: When using the default route: https://example.com/wp-json/wp/v2/categories I want to ...
0
votes
0answers
65 views

How to get WordPress Theme Customizer options in the REST API?

I am trying to work with the WordPress REST Api as a backend for a React application. But I don't understand how to get/fetch the customizer options (check this image for example -> https://imgur.com/...