Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

up vote 4 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

 
discard

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.