Questions tagged [rest-api]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
5 views

Display Products section using an external API

I need to display the below sections in Wordpress website using another API: Products search Products listing with pagination Popular products Stores section Categories and sub-categories section ...
0
votes
0answers
8 views

How to post line_items in json file through woocommerce rest api? [closed]

class _CheckoutState extends State<Checkout> { @override Widget build(BuildContext context) { final cart = Provider.of<Cart>(context); Future<Orders>createOrder(fname,...
0
votes
0answers
10 views

WP REST API returns empty posts despite entries in wp_posts

Using WP API to query posts. There are many entries in wp_posts, but the API always returns an empty array. Request: /wp-json/wp/v2/posts/ Response: [] Request: /wp-json/wp/v2/posts/3553 Response: { ...
0
votes
0answers
30 views

How to add field to custom post type endpoint

I have an endpoint in this address: example.com/wp-json/wp/v2/myendpoint I want to add a field to the endpoint with these codes: add_action( 'rest_api_init', 'create_api_posts_meta_field' ); ...
0
votes
1answer
14 views

Wrong encoding of dynamic block properties problem when loggen in as editor

German umlauts in dynamic block properties ( strings ) are incorrectly encoded/saved in the database, when it's an editor, but correct if edited by an admin. How to reproduce: Create a dynamich block ...
2
votes
0answers
14 views

using woocommerce_template_single_add_to_cart in shop-loop - javascript issues [closed]

We want to show product variations on all product tiles, in all views. I have some code using woocommerce hooks added to functions.php (see below) that does the trick visually but we have several ...
0
votes
1answer
18 views

how to retrieve user via rest api using custom meta and/or email

I've successfully added a custom meta key / value for a user and managed to display it in the rest API however I'm not sure how I can retrieve the user based on this key. For example $fields = ['trdr']...
0
votes
0answers
12 views

Woocommerce hook run after an Order been created through REST API

I'm building a plugin that needs to update data after order creation! I have succeeded in doing that on the website but not in the REST API What I have done is using woocommerce_thankyou that working ...
0
votes
0answers
44 views

Wordpress custom endpoint returning blank response

I have written some custom endpoints in wordpress plugin. Previously when i used wp_send_json to return data from custom endpoint. But as of wordpress 5.5 the usage of wp_send_json is deprecated. Now ...
0
votes
1answer
33 views

Error invalid parameters with REST API

Trying to use the Wordpress API to create a blog post with tags/categories, etc. but running into some errors. I am running the PHP code below outside of my Wordpress instance and get the following: ...
0
votes
0answers
19 views

Securing custom rest API endpoints with public access from PWA

I'am trying to implement a headless woocommerce based PWA on ionic angular stack. I'am now accessing the woocommerce rest endpoints by using client id and secret. To make it more secure iam writing ...
1
vote
2answers
35 views

Adding post fields in wp-json/wp/v2/search

I am trying to add the post (pages, posts) excerpt in the wp-json/wp/v2/search get endpoint but this endpoint seems to not take into account the register_rest_field method. add_action('rest_api_init', ...
0
votes
1answer
21 views

Getting in an exception for get product detail by id in woocommerce REST api

I need to create an order in woocommerce REST API I have tried following code require('../wp-blog-header.php'); header("HTTP/1.1 200 OK"); header("Status: 200 All rosy"); ...
0
votes
0answers
28 views

rest api is disabled [closed]

How do I enable the REST API feature on my wordpress. When I go to my domain http://domain.com/?rest_route=/ http://domain.com/wp-json I get the following: {"code":"rest_api_disabled&...
0
votes
0answers
7 views

How to retrieve posts by category or categories headless wordpress

I am new to wordpress. I have quite a few questions about headless wordpress. I have seen the documentation of wordpress Rest API Handbook. Its pretty clear how to get posts. However, How to retrieve ...
0
votes
1answer
37 views

Filter DELETE REST API calls

I have a custom post type, that can be editable by more than one user. Each post of that type has a field with the user ids who can edit it (kinda like co-authors). But since many users have ...
0
votes
1answer
32 views

Access checks with custom REST endpoints and backbone

I have created a plugin in with several custom REST endpoints. However I can not get the permission callbacks to work. Current user is always '0'. I'm using localize script to send the nonce. ...
0
votes
1answer
23 views

Create API's for custom-post types & custom queries using REST or Graphql

I want to create a cross-platform app using rest APIs for the website (zoetalentsolutions.com). The website is in WordPress and has custom post-types, fields & custom queries. This app will not ...
0
votes
1answer
30 views

How to retrieve custom meta term of category taxonomy from WP Rest API?

First I added custom meta term called Color for Category taxonomy, see the code below Add new colorpicker field to "Add new Category" screen function colorpicker_field_add_new_category( $...
0
votes
0answers
18 views

Custom Rest API POST endpoint with conditionally required parameters

I've spent the last 6 hours trying to figure this out, I'm likely being dumb. I'm trying to create a POST endpoint that has parameters that are required based on the value of another parameter. ...
0
votes
0answers
18 views

Change woocommerce order status by database change

I have a dropshipping client who uses Delphi in his company. He connected his system to my wordpress database and can read and write it. The WordPress site runs on a windows server. How can I make ...
0
votes
0answers
14 views

Get all uploaded images using REST api

I need to get all the images that are uploaded in my wordpress installation using the REST API. I've tried using the wp-json/wp/v2/media endpoint but it will give me only the last 10 images uploaded ...
0
votes
1answer
14 views

How do i post data to url with fields?

I am trying to post some data to a website called Jira and create a new issue there with the data I send. I did try it with postman and it works! But now I just need to implement this in code. So far, ...
0
votes
2answers
20 views

REST filters only firing when I have a param set

I'm trying to use a REST filter to require a certain parameter is set. Using custom taxonomies and custom posts I've been able to make it so when I request /wp-json/wp/v2/car?visible_to=123 That the ...
0
votes
1answer
22 views

No user found when using REST API

When I use a REST route whilst logged in, and call wp_get_current_user(), no user is found. However, the request method, eg POST is processed without issue. Example REST route registration. ...
1
vote
1answer
47 views

WP 5.5 Fatal Error - get_rest_controller() in rest-api.php

I have a site using a customized version of this plugin: https://wordpress.org/plugins/user-tags/ After installing Wordpress 5.5, any of the taxonomy display pages generate this fatal error: PHP Fatal ...
0
votes
1answer
17 views

Is it possible to create new user from external form using REST API?

I created a new user (called external) in a WordPress site with manage users capabilites. I installed Application Passwords plugin to generate a token for that user. Now is it possibile to create a ...
0
votes
0answers
31 views

WordPress + Vue — Single page app giving me 404s when I use query params

I've got my rest api powered site working really well with Vue. Except for the issue of WordPress and urls. Site: http://mytely.ca/ Search for a name or click on a name and the url updates. Now ...
0
votes
0answers
19 views

Sort custom endpoint API by number of views

I have registered a rest field in my functions.php for the API to show: register_rest_field( 'post', 'views', array( 'get_callback' => function ( $data ) { return get_post_meta( $data['id'], '...
0
votes
1answer
24 views

If I use WordPress REST API V2 and someone makes an app using it. Will my site count the posts views from the APP? And if not, then how?

I'm making a mobile app on both Android and iOS and I can fetch the posts and even open them but I don't know if WordPress will count the new views from my App Will WordPress do that automatically? If ...
0
votes
0answers
13 views

WooCommerce Programmatically reset customer password

I'm building a mobile app and need a way to reset the user password through the REST API and I found a hook call woocommerce_customer_reset_password but not working for me it doesn't send the reset ...
0
votes
1answer
59 views

Sending posts from Python to WordPress

We are working on a platform that gets news from various sources and runs some NLP analysis on it. We have the backbone of the backend down, we're now trying to output our results on a feed. Since ...
0
votes
1answer
34 views

Authentication with internal WP_REST_Request and rest_do_request()

How can I add authentication for rest_do_request()? I am trying to add Authentication for a WP_REST_Request object using rest_do_request(). This used within a shortcode that is going to be available ...
0
votes
1answer
18 views

Action on Custom Post publish

I want to send a push notification when a custom post is published ( send in both publish or updated) I tried this code to create a custom post and send a notification. <?php /* Plugin Name: Send ...
0
votes
0answers
13 views

How do I get user comments via WP REST API?

this gets all of the comments: https://example.com/wp-json/wp/v2/comments But when i am trying to get only user comments so its show all comments. https://bd.itcc.net.au/wp-json/wp/v2/comments/?...
0
votes
1answer
15 views

Media gallery images url instead of ID on WP API

I'm getting this in my json response "Gallery Images": [ "1833", "1834", "1835" ], Those are the ID's of my custom post gallery , I need to get the ...
0
votes
0answers
18 views

How to get rest api pagination headers via fetch

I'm creating a react app via create-react-app. My application is very simple, I just want to fetch posts and display the images and the post title. I can't seem to be able to get the pagination ...
0
votes
1answer
20 views

Accessing Custom REST endpoint with rest_do_request()

I've created a plugin that adds a number of REST endpoints. And I am building a settings page that accesses those endpoints. Building UI with Backbone and the interfaces work well. However one of the ...
0
votes
0answers
6 views

Opinion: Wordpress / Woocommerce API or actions and filters?

I was tasked to connect our Wordpress website / Woocommerce webstore with our new CRM Microsoft 365 Business Central regarding products, customers and orders. I started testing a basic connection ...
0
votes
1answer
40 views

WordPress rest API get Posts parent by post ID

I have this url mysite.com/wp-json/wp/v2/posts . it gets me all the posts I want, but what I need is the Parent ID of the Post. Is there an endpoint for example mysite.com/wp-json/wp/v2/parent/{...
0
votes
1answer
21 views

Getting user data via ajax

I am trying to list registered users on the frontend which have a role of 'member'. I have a lot of advanced custom fields for the users though and don't know how to get those fields. I installed the '...
0
votes
0answers
12 views

Best way to retrieve and show data from API to WordPress

Basically, Our Vendor has a system developed in Yii 1.1, Which provides us data through multiple APIs. I am calling 5 different APIs on homepage, and using foreach loop to display the data on homepage....
0
votes
0answers
19 views

WP_Query not ordering correctly

I have two custom user meta fields created with ACF. One is quantidade_corretas_dia_4 (Numeric, integer) and another tempo_dia_4 (Numeric, decimal). I am using WP_User_Query to get users ordered by ...
0
votes
1answer
21 views

Impossible to create a new WooCommerce customer using Rest API

On my website I have created a register page in react and I am using Wordpress headless with WooCommerce on it. So I was expecting to create a new user using the register page i have and as the ...
0
votes
0answers
13 views

Get postID from custom permalink using slug

I'm trying to get the postID of from the URL of articles. I'm using the WordPress REST API to try and do it: https://yas.com.hk/blog/wp-json/wp/v2/posts?slug=someSlugHere When i try grabbing the slug ...
0
votes
0answers
15 views

Wordpress API single post

I'm grabbing a list of posts from Blog A to Blog B using the wordpress API, so far everything is fine, but how do I access the single post inside Blog B? How do I make it so when I access /blog/post-...
1
vote
0answers
267 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 ...
0
votes
0answers
27 views

Filter on the_content doesn't update the content being searched via register_rest_route

I'm trying to get my custom REST route to include search results from a filtered the_content. I'm trying to automatically include the post tag names within each post's content, so that searching can ...
0
votes
0answers
10 views

How to deconstruct a permalink (wp api)

I have a variable set to $this->wp_post_get_permalink() However I need to reset or change the data in the link especially the second part as set in our permalinks dashboard settings without ...
0
votes
0answers
16 views

Updating post status via rest api

I am attempting to remove/hide a post via the REST API and having issues. Currently, I have tried sending the payload as: { 'status':'private' } And I send the request to: /wp/v2/posts/<id ...

1
2 3 4 5
21