Questions tagged [endpoints]

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

Filter by
Sorted by
Tagged with
21
votes
2answers
7k views

How can I use WordPress functions in my stylesheet?

I have my style.php file looking like this. <?php header('Content-Type: text/css');?> #div{ background:<?php echo get_option('bgcolor');?>; } This does not work, but when I do this ...
19
votes
1answer
4k views

Using the Rewrite API to Construct a RESTful URL

I'm trying to generate rewrite rules for a RESTful API. I just want to see if there is a better way to make this work than having to write out every possible rewrite combination. Ok so I have 4 ...
16
votes
3answers
22k views

Add extra parameters after permalink?

How can I add extra parameters after a permalink, specifically if I'm using a custom post type? For example, let's say http://mysite/album/record-name was the permalink. How can I make http://mysite/...
9
votes
2answers
8k 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' => ...
7
votes
1answer
1k views

Dynamic Endpoints

I have a database table outside WordPress that I need to make endpoints for. I've created a page /cars/ where I plan on using a page template to generate links. I would like for the url to look like /...
6
votes
2answers
914 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/' };...
6
votes
0answers
424 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: ...
4
votes
2answers
942 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 ) } ); ...
4
votes
2answers
1k 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 ...
4
votes
2answers
1k views

Make Two Views of Post Type Archive At Two URLs

Updates 6 Feb 14 to make more specific as requested in comments. I have a post type, we'll call it "Projects", with the slug "projects" for which I'd like to offer two views: list view (default) map ...
4
votes
1answer
8k views

How to Rewrite Wordpress URL for a Plugin

I am trying to build a Wordpress plugin here with a custom user admin area. What I would like to do is when the user adds /edit at the end of the page, it should open a page from my plugin. So for ...
3
votes
2answers
1k views

Widget with random posts from a blog for external sites

How can I create a customizable widget with random posts from my blog that can be published on another site as js, iframe or div. Is there any Wordpress plugin for that?
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
2answers
3k views

Add rewrite endpoint to author page + pagination

I want to add a new endpoint to the author page, so that the URL looks like this: http://example.com/writer/username/articles So far, I have: Changed the author base Added a rewrite rule Setup ...
3
votes
1answer
853 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
588 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 ...
3
votes
1answer
2k views

Custom Endpoint Gives 404 Header

I'm trying to write a general endpoint that loads a template. It works as expected with the small exception that the returned header is 404 - Page not Found. Am I missing something in my rewrites? ...
3
votes
1answer
1k views

Sync posts from one WordPress site to another

I want to achieve the following - I have 2 WordPress sites hosted on different servers. Let's call A as sender site and B as receiver site. Whenever I add/update/delete any post in A, it should be ...
3
votes
0answers
705 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 ...
3
votes
0answers
252 views

Endpoint on Specific Page Slug

I have created an endpoint inside of my plugin: add_rewrite_endpoint( 'libstaff', EP_PAGES ); Now I would like to have the endpoint work for one page only based on its slug. In this case, I want it ...
3
votes
0answers
233 views

How make a multi language routes, with rewrite rules or rewrite endpoints?

I want to know a concept of making a multi language routing system for WP. That is the best practice, to make this routing system with add_rewrite_rules for pages post archive etc in part, or to use ...
2
votes
1answer
134 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
1answer
911 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 ...
2
votes
1answer
627 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 ...
2
votes
1answer
836 views

Request object for validate_callback

I'm trying to define a new REST Api endpoint based on WP REST API (version 2) and have question relating to what arguments are available to the validate_callback and sanitize_callback. Is the Request ...
2
votes
1answer
1k 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
1k 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', '...
2
votes
1answer
3k 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
0answers
43 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:/...
2
votes
0answers
148 views

URL endpoint with HTML

I'm using WordPress endpoints to render another template on a post page. How can I add .html to the end of the URL that using the endpoint? Example: Normal URL: example.com/angry-birds Normal URL ...
1
vote
2answers
1k 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( ...
1
vote
1answer
2k 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 ...
1
vote
1answer
2k 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(...
1
vote
2answers
1k 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 ...
1
vote
1answer
40 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 ...
1
vote
1answer
2k views

Why is add_rewrite_endpoint incompatible with /%category%/%postname%/ permalink structure?

I've added a myvar/myvalue rewrite endpoint to EP_ALL which can be added to any URL of a WP installation and a WP plugin will act upon it. That part is cool but it doesn't work when the permalink ...
1
vote
1answer
56 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(){ ...
1
vote
1answer
616 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
1answer
563 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/...
1
vote
1answer
225 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; } ); /...
1
vote
1answer
92 views

Does it still make sense using json endpoint ep_mask now that there's the new rest api? [closed]

I was wondering... Maybe I don't get the point here, don't know. I think that the rewrite api is still usefull for creating beautiful frontend urls for regular users. But I'm not sure on adding a json ...
1
vote
0answers
33 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 ...
1
vote
0answers
51 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 ...
1
vote
0answers
125 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
vote
2answers
1k 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
0answers
36 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
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 ...
1
vote
1answer
121 views

Enpoint Not Found in Rewrite Tag Permalink

I'm trying to make an XML feed show nice and pretty permalinks rather than showing query strings. The problem is I can't get my /products/ endpoint to show up when trying to process my custom rewrite ...
1
vote
0answers
24 views

Rewrite Endpoints not Indexing with google

I don't know if anyone else has found this, but I've created some Endpoints for Authors to now have several pages, but Google isn't seeing any of them. It seems to see the parent url, but not any of ...
1
vote
0answers
725 views

add_rewrite_endpoint() and Custom Post Type Archive

I've got a custom post type. Let's call it books. I'm adding a new rewrite endpoint called pages. I want the url /books/pages/2/ to work but I don't see any rewrite rules generated by WordPress for ...