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
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 ...
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/...
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 ...
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 ...
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 ...
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:
$...
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?
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 ...
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 ...
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(){
// ...
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 ...
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 ...
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');
...
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 ...
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 ...
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 ...
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 (...
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 ...
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 ?
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 ...
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,...
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....
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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:
...
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 ...
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( '...
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 requests.
add_filter( '...
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 ...
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 ...
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 ...
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 ...
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 ...
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?
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,...
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
...
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 ...
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 ...
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 ...
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 ...
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 ...
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' ...
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 ...
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....