Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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

0
votes
1answer
14 views

How might I go about using the API to search for a user by email, but ensuring that it is an exact match?

I am using the API currently to search for a user by email and then getting the ID if the user and then executing a change to the account based on the ID. The only issue is, it seems that when I ...
1
vote
1answer
20 views

WP REST API Post Status Using JavaScript

I am getting my hands dirty in WP REST API. I have gone through a couple of tutorials and have a question using JavaScript to create a new post. In this tutorial, the post var status = 'draft'; (see ...
0
votes
1answer
36 views
+100

How to feed a HTML5's EventSource with a REST API custom endpoint?

So in this quest to build a custom pseudo web chat service with Telegram, I'm trying to get the messages Telegram sends to the server and redirect them to frontend. SSE with HTML5 EventSource seems ...
0
votes
1answer
24 views

Accessing plugin functionality within WP REST API

I'm using the WP REST API to trigger a task from an AJAX request, my callback function attempts to trigger an action found within a plugin, however, that plugin doesn't appear to have loaded. The ...
0
votes
0answers
18 views

WordPress & React Native

I started developing a react-native android app and i thought i'd use Wordpress as my back-end since it supports Rest API. There are several things that i'd like to ask.. I'm using: Advanced Custom ...
0
votes
0answers
14 views

Nginx: Hitting the API with any sort of query string causes 404, “No route was found matching the URL and request method”

I have scoured the internet for 2 days straight reading everything and trying everything I could try but I always end up with the same result. If I hit : /wp-json/wp/v2/users/ It is just fine (most ...
0
votes
0answers
17 views

WordPress Rest API and VueJS best practices? [closed]

I'm in the very early stages of combining WP's REST API and VueJS and want it to be my intro learning experience with VueJS. I can't seem to find a good place / post for general best practices for a ...
0
votes
0answers
25 views

woocommerce php rest api syntax

hello I'm fetching all woocmoorce orders using the woocmoorce php rest api and its working fine but I have a lot of orders and I want to filter them using metadata created by ACF I'm following this ...
0
votes
0answers
13 views

Remove related WP-JSON custom endpoints on plugin uninstall

I am working on removing all the relevant data from my plugin within uninstall.php. I have been searching through the Codex and through numerous answers here and on Stack Overflow and I am either ...
0
votes
1answer
47 views

400 Bad Request - JavaScript App calling Custom wp-json endpoint

I have successfully created a new endpoint/route and can view it via wp-json. Not only that, I can successfully make a post request to this endpoint externally from the browser using the Restlet ...
0
votes
0answers
44 views

Custom Post type with ACF in REST API, how do I get those values?

I use http://github.com/jjgrainger/PostTypes/ to register my custom post types and ACF to add custom fields to my custom post and I want to include in my wp-json response all registered fields per ...
2
votes
1answer
34 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,...
0
votes
1answer
24 views

How can i get the same ajax result using WP REST API instead of admin-ajax?

I have been told that admin-ajax is outdated now and it's better to use REST API instead but I was wondering how can I get the same result of this code which generates a button with a link based on ...
0
votes
1answer
22 views

Why does /wp-json/ not work on the “plain” permalink structure?

I'm given this error: https://image.prntscr.com/image/yUjTXILmQR6lbpAFIb2CyA.png When trying to access http://127.0.0.1/wordpress/wp-json/wp/v2/posts/ but if I change my permalink structure to "Day ...
0
votes
1answer
42 views

Filter post content in REST API

I am trying to allow a plugin to modify the rendered content of posts prior to it being rendered for the WP API, or at least save it as a separate property on that JSON response. For instance, ...
0
votes
1answer
42 views

Custom wp-query in wordpress rest api

For example I have a query with tax and metas and other stuff.. how I can pass it to the rest api so i can call all the data with one call for example this function function load_special_args() { ...
1
vote
1answer
37 views

Rest Api How to get results of child categories with one api call

Example: If I have a parent category 1 with child categories 2,3,4 etc instead of a call like this: /wp/v2/posts?categories=1,2,3,4 i want a call like this (imaging code) /wp/v2/posts?categories=...
1
vote
1answer
42 views

Set featured image using URL with wp rest api

I'm using wordpress REST API for sending posts. I uploaded the media already on the wordpress and i have the urls, now I want while sending the post request for creating a post, i could give it the ...
0
votes
0answers
22 views

Rest API WP-Job-Manager query

WP-Job-Manager For my job module on my site http://itzshowtime.singlestaging.com/jobs/ when i export the rest api json http://itzshowtime.singlestaging.com/wp-json/wp/v2/job-listings The inner ...
0
votes
1answer
12 views

Periodically Query an external API on wordpress site

I am creating a wordpress site that will periodically retrieve data from an API and use that data to update info in the wp_users table. I don't really know how to go about this. I'll start with 2 ...
0
votes
0answers
17 views

WP API REST display custom taxonomy

I managed to display custom post type through API rest but I cannot find a way to display the taxonomies. Let's say "Type" and "Ville" Here is what I have done so far : <?php $response = ...
0
votes
1answer
26 views

Send a get request to wordpress

I want to have a url like this: http://example.com?user_id=23&entry_id=34$nonce=4j54hgc465 When a user clicks on this link, I want to do something with this information like update the user or ...
2
votes
1answer
61 views

WordPress Gutenberg get page template value when post updated?

I need to get the page template name when the post is saved. It fails in save_post hook as $_POST('page_template') is not available. Gutenberg saves post via the REST API and uses ...
0
votes
1answer
29 views

Calling an API to do authentication / user login

I'm relatively new to wordpress and am working on a customized site. I have an API endpoint that I'd like to call to do authentication, because our users are going to have their credentials stored/...
0
votes
0answers
16 views

Is there any harm in using my WooCommerce API Key in Javascript (Ajax) call

Noob here. I have a read only API key that was generated by Woo Commerce. Is there any harm in including this in Javascript AJAX call? For example: myAjaxURL = 'https://dev-measuringselcasel....
-1
votes
1answer
129 views

Call to undefined function upload_is_user_over_quota()

I have two different multisites: www.example.org www.example-two.org On both sites, there are 5 sub-sites. They're hosted on the same server (that I have setup myself using VirtualMin). All 10 sub-...
0
votes
0answers
11 views

Check if user is logged in via WP Rest API [duplicate]

I tried adding this to the response headers for the REST API to check whether or not a user is logged in: $this->send_header('is_user_logged_in', is_user_logged_in() ? true : false); It always ...
0
votes
0answers
15 views

Add “edit” link to third-party application pages

I'm in the process migrating the WP theme to use a third-party client (JS web application). I'd like for people who are editing content to be able to easily click a link to go to edit the page. ...
0
votes
0answers
13 views

WordPress answering to one REST API request and not to another

I'm placing the following request to a site through the javascript Node WP API (wp.posts().after() call) and I get normally the result https://site/wp-json/wp/v2/posts?after=2018-07-31T16%3A56%3A29....
1
vote
0answers
19 views

Getting a Meta from Multiple Meta [duplicate]

i want getting a meta value from multiple meta i getting meta by : $data['cd_meta'] = get_post_meta( $p->ID, 'cd_meta', true); but cd_meta is a multiple meta and i need just one specific meta ...
0
votes
1answer
8 views

Custom rest API route not passing data along

Trying to implement a simple API endpoint on a Wordpress site. I cannot seem to get the end of the URL to pass in to the callback... function fc_category($request) { return func_get_args(); } ...
0
votes
1answer
11 views

Retrieving data about comments and likes

What's the easiest way to fetch the number of comments and the number of likes a post has? I don't see any usefull field when fetching a post (with a request like https://site/wp-json/wp/v2/posts?...
0
votes
0answers
62 views

Allow “wp-admin” edit access through headless WP web application

I have two servers, one that hosts the WP core (server1), and another server running a Node/React application (server2) that fetches posts/pages through WP Rest API on server1. I work with a team of ...
1
vote
1answer
50 views

Gutenberg custom block plugin with custom image sizes

I am using a custum gutenberg block plugin for wordpress(https://neliosoftware.com/blog/how-to-create-your-first-block-for-gutenberg/) This block is using an image but always choosing the full size ...
0
votes
1answer
16 views

Rest API Multisite Site List?

I have a multisite and I’m able to use the rest api for posts/tags/etc for specific sites but I was wondering if there’s a away to get a list of sites on the network using the rest api? something ...
0
votes
1answer
56 views

Rest API encoding of double quotes

I have a standard rest API setup in WP. The results are displayed in an IOS App. Now the problem occurres, that single and double quotes and & are returned in the JSON as Unicode Decimal Code: eg. ...
0
votes
0answers
97 views

Rest API XML Output?

Is there a way to get the the exact same information from rest api endpoints in XML? Example: https://demo.wp-api.org/wp-json/wp/v2/posts I’m not looking for an RSS of latest posts, I want to ...
1
vote
1answer
85 views

WordPress Rest API Create Post

Is it possible to login to my different WP website from another WP website (they have different domain and host) ? Actually, I am trying to create a post on one of my site from my another site using ...
-1
votes
1answer
104 views

How to login via wordpress api and get user details?

I want to login via wordpresss api. I tried with "/wp-json/wp/v2/users" . but it just returns user 1 details. My goal is login via api and fetch all profile information.
0
votes
0answers
78 views

JQuery - Uploading image using Wp Rest API

I am trying upload an image to the wordpress media library with jquery from localhost. Here is my code function get_image_id(filename) { var img = new Image(); img.src = filename; //...
0
votes
0answers
23 views

checking liked user in wordpress rest api

i want check liked user in wordpress rest api. liked user store in custom meta field "cd_liked_disliked_users" and when return it : i use below code for checking liked user but its not work , whats ...
1
vote
1answer
29 views

What is the way to share data between sites in a multisite

We want to display the same data on multiple sites in a multisite. This data needs to be added/edited by the client. We can create a custom post type and use the switch_to_blog function to get the ...
0
votes
1answer
126 views

Rest API basic auth not working

I've setup a basic auth for quick testing a site. $headers = array ( 'Authorization' => 'Basic ' . base64_encode( 'admin' . ':' . 'Str0nGP@$$w0rd' ), ); $url = rest_url( 'wp/v2/posts/1' ); $...
0
votes
0answers
12 views

How to delete meta-field which is registered with register_meta to Rest API

I'm working on a Wordpress integration and updating our WP JSON api v1 to v2. We have custom post types which use two custom meta-fields. One of them should be preserved to the WP's database while ...
0
votes
0answers
36 views

Get srcset and size atribute from Rest API

Is there a way to get the srcset and sizes atribute for a feature image from the posts endpoint in the WP REST API? Or do I need to generate them with JS from _embedded['wp:featuredmedia'][0]....
0
votes
0answers
17 views

How to compare date and string inside a serialized array fro REST API v2? [duplicate]

I have saved a meta data for a single post called "event" as an array like below (serialized for sure) and I would like to filter for "place" and also "date" which will be after or before some sort of ...
0
votes
0answers
19 views

REST-API setup for 2 WordPress sites

I have two WordPress Websites: (1) Is a login-only "backend" site where contractors can login an enter data about their company. (2) Is a front-end site where visitors can fill out a form and ...
0
votes
0answers
134 views

JWT Authentication for WP REST API not allow other users to create posts

I have a custom post type "issues" and also custom role "clients". If my role is admin the i can create my_custom posts but when i change my user role from admin to client it don't allow me to create ...
1
vote
0answers
24 views

Wordpress + REST API v2 and private pages Load by slug

Im creating WP theme based on VUE, anyway I load pages based on slug - no by ID. I use base X-WP-Nonce header authentication, it working well with revision etc. So now I have a private page and my ...
0
votes
1answer
142 views

Woocommerce REST API not considering discounts and coupons

I am trying to create an order on my WooCommerce store from my mobile application using the REST API v2. The order is created successfully but I can't find any solution to the following issues. I ...