Rahul Dev
Rahul Dev

Reputation: 175

How to get the custom endpoint URL in wordpress?

I have created a custom endpoint and i am also able to view it on the browser by visiting http://localhost/wordpress/contactus.

Now, I am having problem finding a proper way to create a hyperlink to visit the page. I searched all over the internet but didn't able to find a solution to it.

Edit: I have used this post https://return-true.com/creating-a-custom-page-with-wordpress-endpoints/ for creating custom endpoint but it didn't tel, how to create the url /dump programatically? I want to know if there is any specific function in wordpress like get_permalink() or so to fetch the url of a custom endpoint?

Upvotes: 0

Views: 1269

Answers (2)

coding_idiot
coding_idiot

Reputation: 13734

You can use inbuilt get_site_url() to get the full url and then append /dump to create the hyperlink. Something like below :

<a href='<? echo get_site_url().'/dump'?>'>My Link</a>

https://developer.wordpress.org/reference/functions/get_site_url/

Upvotes: 0

pixleight
pixleight

Reputation: 198

Not specific to WordPress, but HTML in general:

<a href="http://localhost/wordpress/contactus">Link Text Here</a>

Upvotes: 0

Related Questions