As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [rest-api]

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

577 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5 votes
0 answers
903 views

WordPress REST API call generates nonce twice on every call

I'm trying to login a user via the REST API, and then retrieve the current user on subsequent requests. As per the documentation, in my plugin, I am creating and retrieving a nonce after a successful ...
kvnam's user avatar
  • 101
5 votes
1 answer
3k views

WP REST API returns blank response if post is too long

I'm working on an iOS app that requires the use of WP Rest API to fetch posts. Everything is working smoothly and I fetch posts by ID using this endpoint: https://example.com/wp-json/wp/v2/posts/...
Null TX's user avatar
  • 301
5 votes
0 answers
2k views

How to allow users login to WP from external domain and make REST requests

Basically what i want to do is: Use Wordpress as a login system and data storage for web-application on another domain. Make users able to register and perform REST calls from the application. Let ...
Dariusz Sikorski's user avatar
5 votes
1 answer
1k views

WP-REST API not returning all its endpoints, 404 on documented endpoints

Here's my configuration: WordPress multisite installation on a subdirectory WordPress version is 4.7 Let's say my WordPress site is example.com/mywebsite My WordPress site has published posts The ...
Wright0788's user avatar
4 votes
0 answers
3k 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 ...
Sean D's user avatar
  • 357
4 votes
1 answer
2k views

Creating a post with the REST API, curl and oauth returning 401 error

I'm trying to create a WordPress post using the REST API, OAuth, and cURL. However, I'm running into some trouble. I'm able to create a blank post (no title, slug, etc) using the following code: $...
Dan P's user avatar
  • 41
4 votes
0 answers
274 views

Retrieve CSS and JS From the REST API

Does anyone know of a way to get a list of all registered styles and js scripts in-use on a site via the REST API? Essentially was wp_print_styles() does?
darrinb's user avatar
  • 1,216
4 votes
1 answer
894 views

Using the REST API (v2) javascript client on a private namespaced route

I am using the latest version of the REST API plugin in a project and I've added my routes to a separate namespace (as recommended in the documentation). The javascript client included with the API ...
Dalton Rooney's user avatar
3 votes
0 answers
49 views

WordPress Rest API only returns content when posttype has editor capability

I am trying to request my post via the WordPress V2 Rest API in the backend. For whatever reason the post content is only returned when my custom post type has the editor support enabled. Is there a ...
Dhalucario's user avatar
3 votes
0 answers
491 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(){ // ...
Toni Michel Caubet's user avatar
3 votes
0 answers
881 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 ...
NFB's user avatar
  • 131
3 votes
2 answers
914 views

WP rest api returns 404 only when author param is used

I have a multisite wordpress installation on aws linux, working perfectly fine. The WP Rest api is also working exactly as it should. Except for one single case. /wp-json/wp/v2/posts?author=<some ...
Deepon GhoseRoy's user avatar
3 votes
0 answers
666 views

Wordpress REST API "rest_authentication_errors" doesn't work external queries?

Wordpress REST API "rest_authentication_errors" doesn't work external queries? I was using following experimental codes for experimental purposes. add_filter('rest_authentication_errors', 'auth'); ...
l6ls's user avatar
  • 301
3 votes
0 answers
2k views

Get all post media images via WP REST API

We want to build a back-end for a mobile app using WordPress. We are trying to get all post images, but when we call https://api.com/wp-json/wp/v2/media?parent=58 we are getting only the first image ...
Silviu's user avatar
  • 131
3 votes
0 answers
148 views

Rest API and Custom Fields

how can I create a new post post (custom type, with custom fields) on the front end using rest api and an http request? Is this even currently possible to create a new post with custom fields through ...
Tjb1187's user avatar
  • 31
3 votes
0 answers
161 views

How should an old API version be deprecated gracefully?

When researching and reading about the WP REST API utilization I've seen many topics mentioned about how another version should be rolled out but nothing in the documentation regarding a return for a ...
user9447's user avatar
  • 1,742
3 votes
0 answers
624 views

Prevent wp_insert_user from creating duplicate users

I have a custom plugin that automatically creates a new user via wp_insert_user() if the current user does not exist yet. We use data from our remote ldap server to provide the new user's details (...
Matt's user avatar
  • 31
3 votes
0 answers
3k views

How to get around WP REST API per page limit without pagination?

So I know that using /wp-json/wp/v2/customposts/?per_page=100&page=2 will allow me to bypass the default of 10 returned at a time. But I am trying to return over 2k custom posts. The only other ...
hcu564's user avatar
  • 133
3 votes
1 answer
1k views

Android authentication

I'm using WordPress REST API (Version 2), and I want to authenticate Android native app with my self-hosted WordPress site. How can I perform that using username and password ?
WaWa's user avatar
  • 31
3 votes
0 answers
182 views

WP REST API route request explain

Maybe can someone explain or show additional info about "WP REST API route request" from beginning to the end. Main questions, how handle this request in most earlier stage. For example for ajax ...
Vitalij's user avatar
  • 238
3 votes
0 answers
277 views

Implementing the wp json-rest api

I have a client that wants to use the wp json-rest api to allow third-party sites to push custom posts (in this case property listings) up to our site. I've been looking at using the wp json-rest api,...
Jonathan Foster's user avatar
2 votes
1 answer
61 views

Restrict Image Sizes and Dimensions when Uploading via the WP Mobile App

I restrict image uploads by file size and dimensions on my client's websites using 'wp_handle_upload_prefilter'. However, it appears this function is not called when using the WordPress.com mobile app....
Jim S.'s user avatar
  • 21
2 votes
1 answer
1k views

WordPress REST API not working on localhost

I have a WordPress site running WordPress 5.9.3 that is using a React-based theme, which uses the REST API (v1), to retrieve content and menus from the standard WordPress CMS back-end. However, when ...
Yami Medina's user avatar
2 votes
0 answers
380 views

Testing custom API endpoint with class dependency

Sorry I feel like really stuck here. I have a plugin introducing a new Rest API controller (WP_REST_Controller) with basically a single endpoint which uses a separate class as a client to fetch some ...
dummyDev's user avatar
2 votes
0 answers
51 views

What would be the best way to implement Magic Link logins in WordPress?

On the internet I saw several plugins/services offering a kind of a 'magic login' link functionality. This allows users to sign in without a password but with a magic link. That made me wondering: If ...
ralphjsmit's user avatar
2 votes
0 answers
655 views

Formating content rendered from wordpress REST API as JSON and not HTML

I am new to Wordpress and REST API and I need to read posts from /wp-json/wp/v2/posts with an external application called Intuiface. Intuiface can interpret JSON but the content of the post is shown ...
magikarp28's user avatar
2 votes
1 answer
437 views

How to properly add custom entities in Gutenberg

So, I’ve created a custom endpoint to retrieve some post data I need to retrieve for a feature I’m building for some custom Gutenberg blocks. After reading this answer I started doing my own ...
Camilo's user avatar
  • 31
2 votes
0 answers
151 views

Continue execution after WP REST API response

I am trying to extend the Wordpress REST API with an endpoint that takes Zoom webhooks. Zoom requires a response within 3 seconds or will blacklist your endpoint address, but the processing that I ...
Ari Cooper-Davis's user avatar
2 votes
0 answers
3k views

REST API custom endpoint without authentication for POST method?

I need a custom WordPress REST API endpoint with POST method to receive some data from external domains. The issue is requests are not authenticated & I can't apply authentication methods. There ...
Sarathlal N's user avatar
2 votes
0 answers
271 views

How to force JWT auth for default GET endpoints of Wordpress rest api?

The default GET endpoints (for e.g. http://scintec.net/wp-json/wp/v2/posts/) of the Wordpress Rest api are public and can be accessed by anyone. I am currently interacting with a Wordpress Rest api ...
Navjot Singh's user avatar
2 votes
0 answers
180 views

WP API querying a custom post type and a custom field

I'm developing a site that displays results from a local running race from the past 15 years or so. I have a custom post type called result with several custom fields. Each result looks like: ...
saltcod's user avatar
  • 2,098
2 votes
0 answers
276 views

CORS & Remote access to WP via RestAPI

I have built an app which enables the manager of many WP sites to make RestAPI GET, POST, PUT & DELETE requests which work perfectly when using them from this Apps, when the WP site are hosted on ...
JMB's user avatar
  • 23
2 votes
0 answers
169 views

How to filter Post using Meta Data REST API

I want to list post that filtered by Meta Data I have tried many solutions i found here but i can't make it work. The last solution i tried is to add this to my functions.php add_filter( '...
URaff Joseph's user avatar
2 votes
0 answers
224 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( '...
lowtechsun's user avatar
2 votes
0 answers
528 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 ...
Kyle Calica-St's user avatar
2 votes
0 answers
256 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 ...
AYMEN SOUMER's user avatar
2 votes
0 answers
526 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 ...
Lukas H's user avatar
  • 21
2 votes
0 answers
1k views

Not all featured image sizes available in Rest API

I'm using Vue.js to consume the Rest API for both posts and a custom post type. I'm using the _embed query on the URL for the endpoint to get sizes for the each featured image. The issue that I'm ...
DavidBrown's user avatar
2 votes
0 answers
142 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 ...
Sean's user avatar
  • 647
2 votes
1 answer
452 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?
fefe's user avatar
  • 824
2 votes
1 answer
1k views

Flush Rewrite Rules on init or rest_api_init?

if I'm using the REST API to create endpoints in my plugin, should I be flushing rewrite rules on init or in rest_api_init? I realize that it should be done on plugin activation/deactivation. However,...
Michael Ecklund's user avatar
2 votes
0 answers
2k views

WP Rest API max limit include parameter?

I'm using the rest API to get only selected posts though Rest API. I have used include=<ids> parameter. I have send the API request like: http://example.com/wp-json/wp/v2/posts?include=11,12 ...
maheshwaghmare's user avatar
2 votes
0 answers
90 views

Why is multisite rest API keep giving me results for root site only?

I have a multisite wp installation and am trying to access the posts from the rest api for a subsite. I keep getting the results for the root site instead of the subsite. I'm using Postman to test the ...
averroes's user avatar
2 votes
0 answers
871 views

Full page NGINX (or Cloudflare) caching and WordPress nonces

Goal: I want to cache the full WordPress response via NGINX and exclusively use the REST API for the user specific parts. Issue: I can't get an authenticated nonce to use against the API. My plan ...
JSP's user avatar
  • 447
2 votes
0 answers
1k views

create new post using rest API and set featured Image from an external link

I am new to Wordpress. I need to create a new post from the Rest API which has its featured image from an external link. I can successfully create a new post using the rest API plugin, how do I add ...
Ogundele Adekunle's user avatar
2 votes
0 answers
1k views

Is it possible to update a post meta field through REST API if the format of it when registered is nested?

I am able to get the custom REST API fields using meta key values to be formatted like this: "location": { "lat": "000001", "long": "000002" }, The works fine when I am trying to retrieve ...
drifter's user avatar
  • 223
2 votes
0 answers
343 views

Remote REST request to check login status

There are 2 wp installations, A and B. Is it possible to do a remote rest request from site A to find out if an user is logged into site B? If yes, how? With this information adjustments would be ...
paul's user avatar
  • 21
2 votes
0 answers
227 views

How to filter users on custom meta fields in WP JSON v2?

I am trying to filter users on meta field, say abc is user meta field and value is 123 for user1. I have tried filter parameter with WP query like parameters, but it returns all users. 'search' ...
CodeZel's user avatar
  • 21
2 votes
0 answers
907 views

Create multiple posts with WP REST API at once

I managed it to create single posts with a simple JSON object via the WP REST API like... { title: "My Title", content: "My Content", excerpt: "My Excerpt" } I'm wondering, if there is a way ...
Alex Maiburg's user avatar
2 votes
0 answers
164 views

Login WordPress website using wp-rest api

I am using WordPress 4.8 and i am new to rest api . I have 2 websites , one is www.example.com and second is www.example.com/site2. That is second website is installed inside the first . In example....
Abilash Erikson's user avatar

1
2 3 4 5
12