Creating a custom 'endpoint' using a specific template

Hello, this might be a basic question but I’m quite struggling with it.

I want to create a custom endpoint (something like https://domain.tld/endpoint), this should use a specific Sage 9 template (let’s say …/themes/sage/templates/my-endpoint.blade.php).

Note: This should NOT be a page. I know I can just create a custom page template and add it to a standard WordPress Page post type.

What’s the best approach to this?

Bonus if using Sage 9 best practices :slight_smile:

Thank you!

Hi @apintocr, did you ever figured this out?

It sounds like what you’re trying to do is essentially routing. WordPress’s Rewrite API is the native tool you could use for that (i.e. get the info you need from a query var, then re-write that query var for a pretty link). I also recommend using Cortex for more complex routing: It’s a bit easier to use than the Rewrite API. Unfortunately its “pass a template directly” feature doesn’t work in Sage, but you can get around it with some creative thinking.


Thanks @alwaysblank, I’ve finally used a page to render the endpoint using sth like


But thank you for the Cortex link. I didn’t know it exists.

1 Like