How can I get custom taxonomy page URL in PHP on WordPress?
I have created custom taxonomy name "developer" for posts core on WordPress, this is the URL https://check1.site/developer/Fingersoft/.
Each post has one or 2 developers tag assigned.
Now I want to call this URL in PHP, but I am not sure what code should I use to echo this URL in posts
I tried get_post_type_archive_link()
but it returns current post URL not the developer URL
2
Answers
You can only get the URL(s) of each custom taxonomy term(s), but not the URL of your custom taxonomy itself. For that, you will simply use the function
get_term_link()
WordPress function like in the example below:This will display a list of the "Developer" linked term(s) for the current post.
The function you are looking for is
get_term_link
. It takes either a term object, ID or slug and a taxonomy name and returns a URL to the term landing page.