Skip to main content

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
6 votes
0 answers
1k 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
  • 111
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
  • 321
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
4k 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
  • 367
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
305 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,226
4 votes
1 answer
970 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
53 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
359 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
3 votes
0 answers
553 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
994 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
1k 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
746 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
  • 331
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
152 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
171 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,772
3 votes
0 answers
683 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
  • 153
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
280 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
311 views

Wordpress custom endpoint returns Security violated

Good day, im implement the a custom endpoint for my wordpress site, the intialization for my custom endpoint is: add_action( 'rest_api_init', function () { register_rest_route( '/v1', '/b2buser', ...
Mauricio Trinidad's user avatar
2 votes
1 answer
389 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
0 answers
594 views

Log in user using Wordpress REST API

I am having problems authenticating a user after logging in using a custom endpoint using the WordPress REST API. I'm aware that this is not the perfect approach but I am just trying to make a few ...
Courtney's user avatar
  • 163
2 votes
1 answer
3k 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
701 views

Rest API code to get ID of current user not working: get_current_user_id() gives 0

Background I am trying to write Rest API code to get the ID of the user who triggers the function in question. I found a fantastic answer to this exact question, that was very kindly provided by user ...
Appguy1's user avatar
  • 21
2 votes
0 answers
503 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
672 views

Update image via WP REST API

So I wonder if its possible to update images in the media library via the REST AP? Ive seen a github issue back in 2016 where its mentioned this its not supported in the REST API. Is this still the ...
H. berg's user avatar
  • 121
2 votes
0 answers
54 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
873 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
0 answers
341 views

Setting maintenance mode via REST API

Is there a way to set a WP site to maintenance mode via REST API?
Yonatan Shaham's user avatar
2 votes
0 answers
526 views

REST API: upload media with advanced custom fields (ACF)

Aim I am trying to upload media via the REST API. I have successfully got it working, except for with the ACF data. Problem The media uploads successfully, but the acf fields are blank. Code const ...
Darcy's user avatar
  • 121
2 votes
0 answers
4k 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
246 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
190 views

`rest_user_query` can't access post author in post edit screen

I'm trying to modify the user dropdown in the post edit screen to show only (a) the current user and (b) the current author of the post. I can't do this using wp_dropdown_users_args because the meta ...
Jay's user avatar
  • 175
2 votes
0 answers
311 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
316 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
243 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
669 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
301 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
636 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
171 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
498 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
  • 874
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
127 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
950 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

1
2 3 4 5
12