I have id of WP category on external resource. I know that if I have id of post I can create url like


But what if I know id of category? How can I generate link to it? Category permalinks look like


and I need to use something like


  • Set Permalinks to Plain and visit a category to see for yourself. Dec 27, 2017 at 9:42
  • Custom taxonomy: you can do ?taxonomy_key=a-term-slug e.g. ?sport_category=some-ball-game , I had no luck of finding a way with just term_id ...
    – jave.web
    May 3, 2021 at 0:01

3 Answers 3


If you have category ID you can create link to category like below :

<a href="/index.php?cat=7">Category Title</a>

For more details read from this link :




use get_term_link:

print get_term_link( $category_id, $taxonomy );
  • I cannot use WP functions because I generating URLs on external resource
    – moonvader
    Dec 27, 2017 at 8:21
  • You could use ?category_name=$slug and let WP do a redirect to the actual permalink for you, if that's OK, or does it have to rely on the ID?
    – janh
    Dec 27, 2017 at 8:50
  • I don't have slug I have only list with ids of categories. If I had slug i could generate url example.com/category/$slug but it is not my case
    – moonvader
    Dec 27, 2017 at 9:47

If you have the category id then you can easily get the category URL using the below code.

get_category_link( $category_id );


<a href="<?php echo esc_url( get_category_link( $category_id) ); ?>"  class="view_more_button">View More</a>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.