WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm searching for half an hour now on how to get the url/permalink base in Wordpress (the 'category' and 'tag' value set in the backend). Could you please point me in the right direction?

I want to dynamically print the following - but only replace the tags and category part (not the tag/category itself):

<a href="/tags/my-tag">My Tag</a>
<a href="/category/my-category">My Category</a>
share|improve this question
up vote 7 down vote accepted

You really shouldn't need this, as you should be outputting the URLs via the API: get_tag_link, get_category_link, get_term_link.

However, for the sake of answering the question, they're stored in options:

get_option( 'tag_base' );
get_option( 'category_base' );
share|improve this answer
The reason is that the name or slug of the tag will be the same in dev/testing and production - but the tag_id will vary! So my thought was, that it is more efficient to just grab the set tag_base and append the slug - other than query the database via get_term_link to get the full url. And with the second option, the slug has to be hard-coded, too. – lorem monkey Mar 21 '13 at 8:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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