Articles of endpoints

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: Normal URL with endpoint: Here are the results I’m trying to achieve: and

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 to work ONLY when the page with the slug ‘staff-directory’ is at the end of the URL.

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 1000. When I do it the following way everything goes right: http://localhost:1000/manage-lead/lead_id/1000/?product_id=123455 So I think that I need to add some rewrite rules, so WordPress understands that lead_id and product_id […]

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’ => WP_REST_Server::READABLE, ‘callback’ => ‘get_animals’, ‘args’ => [ ‘id’ ], ] ); It’s now possible to perform api call on url like /wp-json/api/animals/15, but is there a way to declare the param […]

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 object made available for these callbacks? For example: add_action( ‘rest_api_init’, function () { register_rest_route( ‘myplugin/v1’, ‘/author/(?P<id>\d+)’, array( ‘methods’ => ‘GET’, ‘callback’ => […]

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 example should load I am trying to make use of […]

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 add_rewrite_endpoint with bitmask?

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 of this script? For example do I need my login button to link to Or […]

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: add_endpoint( ‘types’, EP_PRODUCT_CAT ); Now I’m trying to create a fairly lengthy URL that combines both the taxonomies: Which works, the types query var is set, the product_cat is […]

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://localhost/sub_category/endpoint/. I’ve removed the “category” from the URL successfully by following this tutorial . But once I remove the “category” from the url, the add_rewrite_endpoint( ‘endpoint’, EP_CATEGORIES ) […]