Questions tagged [rest-api]

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

Filter by
Sorted by
Tagged with
14
votes
4answers
9k views

Filtering multiple custom fields with WP REST API 2

I want to filter posts based on multiple acf custom fields with AND relation. Something like this: $args = array( 'post_type' => 'product', 'meta_query' => array( '...
0
votes
1answer
2k views

WP REST API - get custom taxonomies based on terms & filter

I need to get the list of data's with taxonomy term property_category,based on this property_category having data's like apartment,house,office etc.For example localhost url given http://192.168.0....
0
votes
1answer
389 views

how to filter the data's comparison operators (>= & <=) & range between values using the WP REST API

I'm quit new for wordpress development. Working with property management website with mobile API Development. Here need to filter the data's for based on conditions like greater than and less than &...
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 ...
0
votes
0answers
1k views

REST API And Error Codes - No Message

I'm writing some code which inserts a new post and some postmeta using AngularJs and the REST API. I'm filtering the rest_pre_insert{postype} hook which is allowing me to throw an error when the ...
0
votes
1answer
134 views

Replace content via rest api only?

I am not really looking for code as answer but just the idea. How can i replace content in posts or pages without using short codes or plugins via the recent rest API? In template engines you'd have ...
0
votes
2answers
2k views

Why 'do_shortcode' doesn't work in a REST request?

Why do_shortcode doesn't work in a REST call ? In the example below, do_shortcode exists, but the shortcode isn't interpreted. Route declaration /* Adding a route with callback is ...
3
votes
1answer
1k 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.
0
votes
3answers
3k views

How to get author meta into post endpoint in api v2

I'm trying to output all of the fields in the json result but seem to be using the object incorrectly. I want to add author meta fields to the post endpoint. This doesn't work function ...
2
votes
2answers
2k 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
1answer
7k 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 : { "...
5
votes
2answers
21k views

How to use WP-REST API to login user and get user data for Android app?

I want to use Wordpress REST API to Login and get user data on android app. I am using wp_users table for user and a custom table for user info . I tried writing my own REST API but i for that i ...
1
vote
1answer
2k views

Develop REST API using Wordpress for Android app [closed]

I am an Android developer and new to WordPress. Requirement : is to write rest APIs to Login and get User details after login. All the plugins and wp-rest apis only expose core functionalities and ...
2
votes
1answer
5k 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 $...
0
votes
2answers
171 views

Restructure Objects coming from Rest-Api

I am working with wp-rest api and i have this json structure to work with: [ { "id": 11, "title": { "rendered": "Test-Font" }, "acf": { "schrift": [ { "...
0
votes
3answers
12k views

WP REST API - Retrieve content from page

I already get posts from categories with: http://domain.com/wp-json/wp/v2/posts?filter[category_name]=category-name but how can i retrieve content from page? - [page_name]=page-name for example but ...
0
votes
1answer
3k views

WP REST API format response

I'm using 'WP REST API Version 2.0-beta12" by http://wp-api.org/ to use REST API, available via HTTP of my site's data in simple JSON format. I have formatted my json output to limit reponse field ...
2
votes
2answers
5k views

How would I add custom tables/endpoints to the WP REST API?

I have created custom tables for performance reasons for products, carts, and notifications. I want to make these tables and their data available for normal CRUD via the WP REST API v2. How would I ...
13
votes
5answers
5k views

Does something like is_rest() exist

I am starting a bit with the REST API. If I am not completly mislead, the init action hook is also executed when its a REST API request. Now, I want to execute some code only, when it is not a REST ...
1
vote
2answers
2k views

Why aren't tags and categories added in post request to WP Rest API

I'm using V2.0 and trying to create a post using the /posts endpoint. Here's the payload being sent with my request: var payload = { title : "some title", format : "link", tags: ["...
1
vote
1answer
355 views

body_class REST field in WP-API

I'm building a site with WP-API (v2). I'm attempting to add a REST field according to documentation that includes anything from body_class. However, body_class is returning either one class (one ...
0
votes
1answer
1k views

wp_query json ouput

I'm writng custom endpoints for my mobile app.. My output like this Tried somethings, but getting null values for id, title and content. function my_function($request) { $data = array(); $id = (...
2
votes
1answer
2k views

Wp Rest Api Custom Endpoint for page subpages

I'm tring to add a custom endpoint for a page subpages. Parent Page ID = 151 function list_subpages( $data ) { $subpages = get_pages( array( 'child_of' => $data['151'], ) ); if ( ...
0
votes
1answer
1k views

Attach featured image to custom endpoints

I went through this article and create a custom endpoint so that I can specify multiple meta key and value pairs for filtering. However I have no clue to attach featured image on this result. How can ...
6
votes
1answer
1k views

WP REST API create post authentication issue

I am getting a 401 or 403 error when trying to create a post from front end. I am using angular in the front end and I want to use basic authorization. I have enqueued the api and created the nonce: ...
5
votes
1answer
2k views

wp rest api v2 return json_no_route

i am using WP rest API v1 and everything is ok. But now i want taste some WP rest API v2. the problem is, when i cal: mysite.com/wp-json/wp/v2/posts or: mysite.com/wp-json/wp/v2/post or ...
0
votes
1answer
175 views

Best Way to detect unique posts in wp rest api

I am developing an android app for my WordPress blog. I have some bad trouble to detect and get post. So first I give u a vision from what I am into: I want to get post from past, so I do this: Get ...
17
votes
7answers
774 views

REST API purpose?

First of all, I understand that this is a plugin at current point but it is most certainly almost part of WordPress anyway. So I hope that this is not getting flagged as off-topic. I've read their ...
0
votes
1answer
68 views

Connecting a wordpress site to an AngularJS APP

Currently I have a application that needs a blogging system added. The application is built with an AngularJS front-end and a python/Django back end. I wanted to use wordpress as the blogging system ...
3
votes
1answer
4k views

Retrieve all users from wordpress database via REST/JSON API

I've read that the WP REST API v2 retrieves only users that have made a post for the blog. I'm developing an iOS and Android app that needs to use the Wordpress registration. How I could retrieve a ...
0
votes
1answer
3k views

WP Rest API and json_decode()

I'm getting familiar with the WP REST API 2 plugin and I started following the amazing directions from Torque's Guide. Everything seems pretty clear but I'm having trouble understanding this error (...
0
votes
1answer
2k views

WP REST API - log in with Facebook

We're developing a mobile application for a web site that uses Wordpress and exposes a REST API through the WP REST API plugin. We have very little prior experience with Wordpress. One of the ...
3
votes
0answers
163 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 ...
9
votes
4answers
15k views

Get post count in wp rest API v2 and get all categories

I want to get the count of my posts. I think use wp-json/wp/v2/categories?page=1 >> count it's a good way to go. But using above solution is not a cup of tea in term of speed and i don't know how to ...
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. ...
4
votes
1answer
794 views

REST API: How can I restrict a custom post type to only be accessible by authenticated users?

I have a custom post type configured to be accessible via the WP Rest API v2. How do I lock the access to this custom post type so that only the authenticated users can perform GET requests?
0
votes
0answers
821 views

GET request for media files in WP REST API 2 results in an empty array

EDIT: I have reported the issue to the development team of the plugin and they have resolved it in BETA10 version of the plugin. I have been trying to fetch all the media files from the REST API ...
18
votes
4answers
42k views

How to use OAuth authentication with REST API via CURL commands?

I am trying to use the WordPress Rest Api with authentication to get more data from the API. I have installed the Oauth plugin, rest-api plugin, and gotten API credentials from WP-CLI. I have ...