Questions tagged [rest-api]

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

Filter by
Sorted by
Tagged with
4
votes
0answers
201 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
1answer
610 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
1answer
3k 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' => ...
3
votes
2answers
5k views

Verify nonce in REST API?

I would like to understand the best practices regarding nonce validation in REST APIs. I see a lot of people talking about wp_rest nonce for REST requests. But upon looking on WordPress core code, I ...
3
votes
1answer
9k views

Process checkout using WC REST API

With a main site using WordPress/WooCommerce, and a remote site serving front end; is it possible to process checkout form using WooCommerce REST API, and receive a redirect URL to the selected ...
3
votes
1answer
307 views

How to use _embed when using _fields?

It seems that if you use _fields in an API request also containing _embed, the _fields filter will filter out all embeds. The following request: domain.com/wp-json/wp/v2/posts?_fields=link,title&...
3
votes
1answer
17k views

WP REST API “rest_no_route” when trying to update meta

I have been working with the WP REST API and all GET (read) commands pull the data I want from both built in and custom post types (this plugin was a godsend btw to help). I can also POST to create ...
3
votes
1answer
12k views

WP Rest API v2 return posts with specific tag

I am trying to get posts from blog: http://christianconcepts.com/ which are tagged "appcontent". I tried this querry: http://christianconcepts.com/wp-json/wp/v2/posts/?filter[tag]=appcontent but ...
3
votes
1answer
5k 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 ...
3
votes
1answer
675 views

WP REST API core major changes

As of version 4.7 of WordPress the REST API plugin merged into the core. I notice the following major changes: filter[key] = value not working anymore. ?taxonomy = slug not working. Works only by id. ...
3
votes
1answer
2k views

WordPress 4.7 REST API endpoints

So with WordPress 4.7 the REST API endpoints will be merged into the core which I'm really looking forward to. On setting up a test site with the 4.7 beta 4 installed, I wasn't able to find the ...
3
votes
3answers
1k views

How to check WordPress website username and password is correct

On my site i have one form for client to submit their WordPress site details. On that form containing these fields WordPress admin url, username, and password. I want to check their login details are ...
3
votes
2answers
3k views

WordPress REST API - JSON “Rendered” Content Incorrect

i'm working in android application that use wordpress rest api to get blog from website to , i don't have any knowledge about php or wordpress , but i take some time to learn about it , any way my ...
3
votes
2answers
5k views

Increase per_page limit in REST API

WP 4.8.2 We need to increase the per_page limit on responses to a REST API request. afaik – the limit is 100 There used to be a way to filter that parameter, but it seems this filter hook is no ...
3
votes
3answers
22k views

wp-json/ return 404, but wp-json/wp/v2/ works fine on my nginx server

When I access my WordPress site as www.example.com/wp-json/ I got this 404 error. `{"code":"rest_no_route","message":"No route was found matching the URL and request method","data":{"status":404}}` ...
3
votes
1answer
3k views

Does the REST API (official) support custom post types?

Having browsed the official WordPress REST API site - and looking at the various endpoints - I cannot find information of custom post types. I appreciate there is the WordPress REST API Plugin that ...
3
votes
1answer
9k views

How to filter by category in REST API, excluding posts also in other category term?

I'm using REST API to load a several posts from other site, each post must belong to a different category. However I have one "Featured events" category, that includes posts also shown in other ...
3
votes
1answer
2k views

WP MultiSite API - Create new sites

I'm building an app for iOS/Windows. I want to allow my users to register / create a new sub site on my domain via the app. How can I achieve this? Does the REST API allow this? Thanks.
3
votes
1answer
636 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 ...
3
votes
1answer
4k views

Does the Wordpress API work with multisite?

I’ve found next to no information on whether the rest API works with Wordpress multisite setup. Does it?
3
votes
1answer
1k views

How to: Rest endpoint returning empty object

I'd like to implement a custom REST endpoint that can also return an empty object. However, in the case where it should return an empty object, the empty associative array returned by the callback is ...
3
votes
1answer
3k views

How to get the attached gallery in the rest API?

I just added a gallery to my post and want to access its images through the rest API. In the rest API, I can access the attachments of a post. But those attachments have other images, not in the ...
3
votes
1answer
5k views

WP API : date_query parameter

I'm using Wordpress API just to perform some tests. I'm currently working with the date_query parameter, which, in my case, doesn't work as expected. Just consider this request : https://wptest....
3
votes
1answer
1k views

Retrieve custom fields on Categories, using WP-API

I've added a single Advanced Custom Field to the categories taxonomy (that appears to work as expected) and am trying to retrieve it along with the categories using the REST API, via /wp-json/wp/v2/...
3
votes
1answer
3k views

How to filter or search the posts using postmeta tables custom meta fields with wordpress REST API

I'm new to wordpress and also working with WP REST API for mobile application development for the wordpress website. Here I want get data's filter & search based post meta custom fields. I've ...
3
votes
2answers
886 views

How to get all posts from parent and children categories?

I am trying to get all posts from category products. My template looks like this: /products/PARENT_CATEGORY/CHILD_CATEGORY. What I need is all the posts from every CHILD_CATEGORY. I try to access it ...
3
votes
1answer
472 views

Get loading state of wp data selector

I have a custom block that shows the assigned taxonomy terms for the current post. I'm trying to show a loading spinner while those terms are loading in the background. Let's say I have a selector ...
3
votes
1answer
2k views

Gutenberg - how to correctly perform ajax request on backend

I have simple block with server-side rendering on frontend. PHP: register_block_type( 'some/block', array( 'render_callback' => 'render_my_block', 'attributes' => array( '...
3
votes
1answer
3k views

Rewrite /?rest_route=/ link to /wp-json/ without changing default permalink structure in apache

How to rewrite url of wordpress rest api from http://example.com/?rest_route=/wp/v2/ to http://example.com/wp-json/wp/v2/ without changing (default) permalink structure? Need this for apache (htaccess)...
3
votes
1answer
164 views

How to make an meta_query optional?

I added this snippet of code to my functions.php to be able to make a request to a custom post type and filter by book_id add_filter( 'rest_gallery_query', function( $args ) { $args['meta_query'] = ...
3
votes
1answer
6k views

Adding Wordpress API Endpoint With Multiple Parameters

So I understand for the most part how the wp rest controller works, what it is doing and why it is the best way to do it. The trouble I am having is wrapping my head around the regular expressions in ...
3
votes
2answers
1k views

Override json encoding in rest api

I'm trying to create a secure download plugin. I found the rest api the best option for this task, but i cant change headers like Content-Type:. In the register_rest_route callback these headers ...
3
votes
2answers
1k views

Wordpress pods io - Rest API for fetching fields information for custom post type

Hi I have created a custom post type using pods io. Whenever I hit the rest API for a custom post type, I get data for all the posts created using that post type. But what I need from rest API is the ...
3
votes
2answers
3k views

Get blog title with REST v2

I can't find the answer after searching, so... How do I get the title of a site using the REST API v2? All I can find in the API docs are the posts, pages, tags,...
3
votes
3answers
1k views

Show custom post type endpoint in REST API just if user has capability

I created a custom post type for WP, that should just be visitable for user that have a custom capability read_cpt. Within templates and pre_get_posts I can run checks to include or exclude the CPT by ...
3
votes
1answer
4k views

register_rest_field for custom taxonomy fields that are assosiated with custom post type

I am trying to register a rest field for my custom taxonomy's custom meta fields. I followed the tutorial at Modifying Responses . The code worked great for adding a rest field for post meta data for ...
3
votes
1answer
8k views

Custom route for WP-API gives “rest_no_route” value

I am following this tutorial to create custom end points to WP-API . I am always getting this error on hitting /wp-json/custom-plugin/v2/get-all-post-ids/ on postman to test : { "...
3
votes
1answer
2k views

WP REST API V2 - Modifying responses

I am trying to modify the response object of a WP REST API (v2) call following this guide: http://v2.wp-api.org/extending/modifying/ I have a post type called Careers and a taxonomy called Regions. ...
3
votes
2answers
2k views

WP REST API, query total posts in a category

I have just started playing with the WP REST API and found that when querying posts that there is a limit of 10 post per page unless specified. What I would like to know if is is possible to return ...
3
votes
0answers
28 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
0answers
2k 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 ...
3
votes
0answers
429 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
2answers
3k views

404/500 error on /wp-json

I get 500 error on wp-json. if I try to echo get_rest_url() I get example.com/wp-json, which then gives me error 500. I added RewriteCond %{REQUEST_URI} !^/wp-json to my .htaccess, which gave me 404 ...
3
votes
0answers
130 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
0answers
2k 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
1answer
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
0answers
173 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
0answers
268 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
1answer
13k views

Get more than 10 posts in a specific category with the wordpress api

I'm currently building an Ionic app that uses the Wordpress api. I can retrieve posts in a specific category by using the following: // Retrieve filtered data for the categories to show posts. ...
2
votes
1answer
6k views

How Do I Add User Custom Field to REST API Response?

I am writing a WordPress theme that adds several custom fields to the user profile using the following function function add_contact_methods( $profile_fields ) { // Add Social Media Fields $...

1 2
3
4 5
21