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 tagged [endpoints]

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

0
votes
1answer
18 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
32 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
38 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
49 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
0answers
66 views

Custom endpoint without loading entire Wordpress

With only WooCommerce installed the Wordpress rest api loading time is above 1.5s, this is unpractical, so i'm trying to create a custom endpoint and define SHORTINIT to true to load the minimum ...
0
votes
1answer
45 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
30 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
495 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
26 views

Rest API Custom Endpoint with percent % character always returning 404

I have an endpoint like this:- function foo_hook() { register_rest_route( 'sample_namespace/v1', '/author/(?P<author_name>[a-zA-Z0-9-_\%]+)', array( 'methods' => 'GET', 'callback' => '...
0
votes
0answers
12 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
81 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 ...
0
votes
1answer
300 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
822 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(...
0
votes
0answers
51 views

How to use endpoint with pagination in woocommerce

I added endpoint EX: "my_list" like that: add_action('init', 'theme_add_my_account_endpoint'); function theme_add_my_account_endpoint() { add_rewrite_endpoint('my_list', EP_ROOT | EP_PAGES ); ...
1
vote
2answers
622 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
703 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
747 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
82 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)...
0
votes
1answer
504 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 ...
0
votes
0answers
37 views

Help with Rest API custom endpoint

I am trying to slim down the JSON returned when using the Rest API. I am able to get the data I need using "_embed" parameter in the query like this: https://foo.com/blog/wp-json/wp/v2/posts?_embed&...
4
votes
2answers
594 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
1answer
490 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-...
2
votes
1answer
480 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
444 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 ...
1
vote
2answers
878 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
455 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
637 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
224 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 /** * * ...
1
vote
1answer
1k views

How can I get users email (and additional data) from the rest API?

How can I get the email adress from the users by using the REST API? I'm authenticating with nonce, and it seems to be working since I can do POST requests and change stuff. Do I have to add something ...
0
votes
1answer
690 views

Custom rest api endpoint response json problem

I am using WP 4.6 which the rest api have not yet included in the core. But I still can use rest_api_init to create an api endpoint. The problem is how can I change the endpoint response into proper ...
0
votes
1answer
922 views

AMP version of front page without plugin

The below code is working for all pages and posts but it is not working for front page anybody helps me. e.g HTML version www.example.com and AMP version www.example.com/amp How to include amp ...
3
votes
0answers
35 views

Removing “category” from URLs then “add_endpoint()” won't work…

For example, the original URL would be http://localhost/category/sub_category/. What I want is http://localhost/sub_category/, furthermore, I want to add an endpoint to the URL which looks like http:/...
6
votes
0answers
346 views

Custom Taxonomy Endpoint Pagination using paginate_links()

The Setup I have 2 taxonomies and 1 post type: Post Type: products Hierarchical Taxonomy: product_cat Nonhierarchical Taxonomy: product_type The product-category has a defined endpoint: ...
0
votes
1answer
1k views

WP Rest endpoint with custom post type and ACF Fields

I am trying to create a REST api get to fetch projects and return them as JSON. I am trying to create a new endpoint, where I am trying to fetch the CPT and the other Advanced Custom Fields. So far I ...
0
votes
1answer
50 views

How to add a rewrite endpoint to unattached media?

I'm trying to add an endpoint to unattached media items. This is what I hope to achieve: example.com/attachment-slug/foo/ ...where foo is the endpoint I'm trying to add. Here's my code: add_action(...
0
votes
1answer
84 views

How to get custom or filtered endpoints in WordPress API?

I am using WordPress API to show posts. How can I get custom or filtered endpoints in WordPress API? I want only the following items: Post title Post content Post Date Post categories Post featured ...
2
votes
1answer
882 views

Rest API Custom Endpoint with space character

I'm trying to add an endpoint with the following: register_rest_route('namespace/v1','custom-search/(?P<search>[a-zA-Z\s]+)', array( 'methods' => 'GET', '...
1
vote
1answer
175 views

How to create an endpoint without creating sub endpoints?

I'm trying to create a new endpoint using add_rewrite_endpoint(). Here's my code: // Add query var. add_filter( 'query_vars', function( $vars ) { $vars[] = 'my-endpoint'; return $vars; } ); /...
0
votes
0answers
89 views

Multiple Permalink Patterns for one page

Disclaimer: I've had a look at quite a few similar questions and haven't found any that answer my question. If you think otherwise, kindly reply. :) Alright, so I have one page: /classifieds/ What I'...
8
votes
2answers
5k views

Wordpress Rest API custom endpoint optional param

Is it possible to use register_rest_route() with optional parameters in url? Let's say route is registered this way: register_rest_route( 'api', '/animals/(?P<id>\d+)', [ 'methods' => ...
1
vote
0answers
35 views

A case for Hierarchical Custom Posts

So I have 3 Custom Posts created with the Types plugin (the plugin should be irrelevant, anyway): 'Hotels', 'Rooms' and 'Webcams'. These last two are hierarchical, with 'Hotels' as their parent, set ...
-1
votes
1answer
1k views

Using Wordpress.com API to retrieve featured images

I'm using the wordpress.com API to access a blog's content: https://public-api.wordpress.com/wp/v2/sites/MYSITENUMBER/pages It works great, I can access all the text content I need, however, I ...
3
votes
1answer
1k 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
0answers
586 views

Create a php callback/endpoint for an OAuth script

I am attempting an OAuth call to a 3rd party service but having issues with my callback script. I have a file oauth.php that is within my plugin directory. First question, do I need to go to the url ...
2
votes
1answer
727 views

rewrite endpoint not working on home page

I'm using this code to create a rewrite endpoint in a custom plugin: function setup_seo_endpoing() { add_rewrite_endpoint( 'item', EP_ALL ); } add_action( 'init', 'setup_seo_endpoint'); This ...
0
votes
2answers
509 views

Is there a better way of handling AJAX requests in Wordpress?

I'm currently building a pretty straightforward plugin, but it relies quite extensively on AJAX requests. I'm using the standard admin-ajax endpoint for the requests, but I find that it seems to be ...
0
votes
2answers
253 views

How to use endpoint, but remove/rewrite endpoint base?

I've been messing around with rewrites and query_var to generate some listings, for example: ~/my-page/?my_var=1 ~/my-page/?my_var=2 ~/my-page/?my_var=3 After perusing StackExchange and the ...
1
vote
1answer
2k 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 ...
2
votes
1answer
499 views

Multiple endpoints in one URL

I am trying to add multiple endpoints in one url like: http://localhost:1000/manage-lead/lead_id/1000/product_id/123455 But this way the query var lead_id is equal to 1000/product/123455 and not ...
1
vote
1answer
1k views

My php header() function is not working [closed]

// Edit: I figured it out. Hours and hours of banging my head against a wall and it turns out all this needed was one simple line: ob_clean(); Somewhere in some included file there's probably one ...