Questions tagged [endpoints]

Custom additions to permalinks for any kind of type (archives, posts, root).

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

Wordpress Rest API custom endpoint for RSS feed

I know how to register custom endpoints for Wordpress REST API and actually use it to output podcasts from my website like this: register_rest_route( 'myradio/v1', '/podcasts/(?P<id>\d+)', ...
0
votes
0answers
42 views

Mutiple url rewrite rules and get every params

I am creating a messaging system where I have 4 sections (1)inbox (2)sent (3)draft (4)unread so I decide to go with Wordpress add rewrite rules I already add one rewrite rule section. ...
0
votes
0answers
15 views

Display WooCommerce account endpoint to specific user role

Here I have created a custom My Account endpoint for listing all the Costumes in CPT for that logged in user. Currently this endpointfile is included in the main plugin php file ( my-awesome-plugin....
0
votes
1answer
38 views

Custom account page that accepts a query parameter

I am trying to add a new account submenu page that takes a query parameter. I have the following which works: add_action('init', function() { add_rewrite_endpoint('scheduled-order-create', ...
1
vote
0answers
30 views

Custom endpoint to get all custom taxonomy terms

I'm trying to build a custom endpoint to get all terms from custom taxonomy the taxonomy name is cats I'm using this code function wl_cats() { $args = [ 'numberposts' => ...
1
vote
1answer
35 views

Where to add one custom end point and its function?

I just need to register one custom end point and its function (simple code). Where should I add the code in the sources files of WP?
1
vote
0answers
40 views

Using WP-API and SSE not authenticating user ID

I am using the wp-api to create a custom endpoint for my data: add_action( 'rest_api_init', function() { register_rest_route( 'mb/v1', '/sse/', array( 'methods' => 'get', ...
2
votes
0answers
42 views

How to handle Gutenberg wp.data async errors?

When using wp.data.select('core').getEntityRecords(...), there is a special selector for loading states wp.data.select('core/data').isResolving(...). But what about actual errors -- backend validation ...
0
votes
1answer
103 views

Update block once an API request returns with a value

I've got a block that allows the user to enter a script when in edit mode, then sends this script to a REST endpoint which returns a WP_Post representing a media file which is then displayed to the ...
0
votes
1answer
670 views

Get post from custom REST endpoint in Gutenberg

I'd like to get a post object from a custom REST endpoint within a Gutenberg block. The REST endpoint returns as part of its JSON payload an array with a "post" key which contains the contents of the ...
1
vote
1answer
19 views

Is there anyway to format my EndPoint URL in WordPress?

I have wrote an endpoint in WordPress and it works just fine. The problem is with the URL. The current format of the URL request must be like this: https://iotkidsiq.com/wp-json/zaindob/v1/sync_order/...
0
votes
1answer
279 views

Implementing a URL Shortener

I want to create a URL shortener where I use a REST API endpoint request to get a shortened url, e.g.: mywebsite.com/wp-json/wl/v1/shorten?url=url-to-shorten.com Where I get a response with a ...
0
votes
1answer
91 views

WooCommerce Endpoints content

I have a custom plugin that is integrated with woocommerce. I want to display listing records in the user's profile and have successfully done so. Creating the end points. refreshing the permalinks. ...
0
votes
0answers
19 views

Create a custom role to can access only a custom api endpoint to fetch data

I have a small external app which is communicating with a wordpress custom REST API endpoint, in the meaning is requesting some data aggregation from web but will never push back data to wordpress DB. ...
0
votes
0answers
22 views

Create an area for the site visitor

I have a need to create an area for the site visitor, I need to create the following structure, mysite.com/dashboard and myite.com/account I thought I would use rewrite endpoint API, but I only ...
0
votes
2answers
310 views

Is this a correct usage of ob_start() in my WordPress project?

I have extended WooCommerce to create a custom endpoint. This endpoint, points to a template that has a form to save user meta data. When the form is submitted I want it to redirect to another URL. ...
0
votes
0answers
262 views

How can I secure my custom rest api endpoint or add under a already existing rest group

Creating a custom REST Endpoint I search a way to secure the route with JWT or integrate my endpoint under Woocommerce rest routes which already has an authentication logic. The perfect solution for ...
0
votes
2answers
375 views

Need to forward Data from WooCommerce Webhook sent to same site Wordpress REST API custom endpoint

I created a Wordpress REST API custom endpoint to be used as a Webhook URL in WooCommerce in order to convert the received data and then send it to a third party system, but the endpoint apparently is ...
1
vote
1answer
382 views

Creating an endpoint in wordpress

I'm writing a plugin that will allow some of my installs to talk to each other and share specific information. I wish to specify an endpoint such that example.com/path/here is where the other site can ...
0
votes
1answer
114 views

How to require files in a custom endpoint

I am working on a custom endpoint to handle ajax media uploads with media_handle_upload(). I have created a custom endpoint with a route that is tested and works, however when I try require the ...
0
votes
1answer
1k views

Can't get POST data in API endpoint callback

I have this: add_action( 'rest_api_init', function () { register_rest_route('my-project/v1/form', '/post', array( 'methods' => 'POST', 'callback' => 'post_form' ) ); }); I called ...
0
votes
1answer
417 views

Can I define multiple callback methods depending on the call method?

He is my current custom API: add_action( 'rest_api_init', function () { register_rest_route('my-project/v1/form', '/get', array( 'methods' => WP_REST_Server::READABLE, 'callback' => '...
0
votes
1answer
315 views

POST request not going through?

I'm still trying to see clearly in some aspects of the API. I have a custom route add_action( 'rest_api_init', function () { register_rest_route('my-project/v1/', '/form/post/', array( '...
4
votes
2answers
6k views

Why is my custom API endpoint not working?

I tried to include this code in my plug-in php files as well as in functions.php. (In the end I would like it to be in the plug-in's php file but I'm not yet sure if possible, that would probably be ...
2
votes
0answers
56 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 ...
0
votes
1answer
101 views

Custom route and query

I am trying to use a custom WordPress route and function, but I am getting a route and function not found error. Below is my code but I am not sure where it is breaking: add_action('rest_api_init', ...
0
votes
1answer
65 views

How to call code when adding WooCommerce menu items via woocommerce_account_menu_items

I'm inserting menu items similar to the code example at https://wordpress.stackexchange.com/a/277080/137417, but I haven't encountered endpoints before and the documentation and tutorial I've looked ...
0
votes
1answer
881 views

REST Endpoint API 404

I recently have been led to REST Endpoints within WordPress on another one of my posts. However following the guides/provided solution results in a 404 of the expected endpoint API url. My code is ...
1
vote
1answer
109 views

WordPress custom slug (endpoint) and compare all links

I work on the one i18n function. It will work with subdir. For example: eg.com/hello-world/en For this I'm support EP_ALL for the WP custom endpoints. function lang_add_endpoints(){ ...
0
votes
1answer
813 views

Associate the “add_rewrite_endpoint” and “$_GET”

I have an i18n class. The class find lang tag. For example: "?lang=en" And i want it work with subdir. For example: eg.com/en and eg.com/hello-world/en For this i am using: add_rewrite_endpoint ...
0
votes
1answer
155 views

How to fix AWS SNS API end point code that cause site not to load?

I'm trying to create an API endpoint in a Wordpress site that can receive AWS Simple Notification Service notification. I have this working now, but on the front end, the site does not load. Here are ...
1
vote
0answers
104 views

Manage custom post type in woocommerce /my-account/ page

I am hope for your help I have a custom post-type on my site - "Campaigns", I want to make that the user can on the page /my-account/campaigns was able to see the list of his posts, delete / edit ...
6
votes
2answers
1k views

In Gutenberg, now that withAPIData is being deprecated, how can I do an async call to a custom endpoint?

I have this working in my plugin and all is well with the world: edit: withAPIData( props => { return { roles: '/matt-watson/secure-blocks/v1/user-roles/' };...
0
votes
0answers
14 views

Debug info from request handler

I'm adding custom request handler using add_action and register_rest_root. Sometimes it's hanging and I'm stuck without any output. I would like to use something like echo "Label"; to debug my code. ...
1
vote
0answers
208 views

add_rewrite_endpoint returns 404 on archives

My endpoint works on all kind of single pages and homepage, but it returns 404 in archive pages, either categories or custom taxonomes. I have reflushed rewrites but I don't get it work. This is my ...
-1
votes
1answer
665 views

If YITH Wishlist page is set to the WooCommerce my-account endpoint, the endpoints stop working all together. Any solution?

When using YITH to display the wishlist in the my-account endpoint of WooCommerce, the wishlist works fine, but the endpoints stop working. If we change the page to anything else other than the my-...
1
vote
1answer
3k views

“rest_no_route” - Debug error

I am using Wordpress 4.9.5 and I want to create a custom endpoint like the following: <?php add_action('rest_api_init', 'miningRigsRoutes'); function miningRigsRoutes() { register_rest_route(...
2
votes
2answers
2k views

Add rewrite rule for rewrite endpoint

I've created an rewrite endpoint with the add_rewrite_endpoint function … here is the whole contruct: // Register to query vars add_filter( 'query_vars', 'add_query_vars'); function add_query_vars( ...
0
votes
1answer
3k views

How to add an endpoint for my custom post type? /wp-json/wp/v2/posts is working but it didn't in the custom post

function create_api_posts_meta_field() { // register_rest_field ( 'name-of-post-type', 'name-of-field-to-return', array-of-callbacks-and-schema() ) register_rest_field( 'post', 'post-meta-fields', ...
2
votes
1answer
2k views

Query the REST API for a Tag by slug

Is it possible to query the API directly using a tag slug rather than a tag ID? Or do you have to query the main tags endpoint to find out its ID? For reference, you can fetch a tag this way: GET /...
2
votes
1answer
293 views

How to have multiple rewrite endpoints in the same URL?

I'd like to add multiple query_var / value pairs to any URL. For example the base URL of a page is: example.com/nice-page/ I can already achieve one endpoint like (for example, an on-page subgallery)...
2
votes
2answers
3k views

How to stop WP API endpoint from caching?

I have a simple endpoint. Its GET, I pass it an ID parameter and it uses this ID to make a curl call. The endpoint then responds with a couple pieces of info json_encoded. The issue is that this ...
4
votes
2answers
1k views

REST API endpoint for elasticpress autosuggest

The AJAX, which is part of Elasticpress, looks like this $.ajax( { url: epas.endpointUrl, type: 'GET', dataType: 'json', crossDomain: true, data: JSON.stringify( query ) } ); ...
3
votes
2answers
2k views

Woocommerce My Account Endpoint - how to get ID parameter from URL?

I'm using WooCommerce v3.2.6 and WordPress 4.9.1. I've added an endpoint to the WooCommerce myaccount area (view-subscription): function my_custom_endpoints() { add_rewrite_endpoint( 'view-...
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 ...
1
vote
1answer
820 views

Add sub subpage endpoint in woocommerce

I already added new endpoint to my account page, "my-account/My-New-Endpoint". I would like to add sub page endpoint to that like "my-account/My-New-Endpoint/New-Subendpoint" I can't find any info ...
4
votes
3answers
2k views

WooCommerce: Can't use wc_get_products for custom REST API endpoints

I'm trying to create some custom REST API endpoints which get products with some special conditions, for example, one endpoint for featured products. I tried to use the wc_get_products function like ...
1
vote
1answer
823 views

Woocommerce Customs Endpoint

i create snippet for added custom endpoint and this my code: /** * Register new endpoint to use inside My Account page. * * @see https://developer.wordpress.org/reference/functions/...
0
votes
0answers
981 views

Custom Rest API namespace and endpoints are responding with 404 & 503 errors

I am new to WordPress plugin development. I was developing a plugin for WordPress that would be used to create mobile apps for WordPress Bloggers. The whole source code of the plugin is at:- https://...
0
votes
1answer
493 views

Get The latest post from a category

I am using below code to get the latest post from a category www.mysite.com/wp-json/mynamespace/v1/latest-posts?category=it but an error is showing <?php /** * * ...