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="https://wordpress.stackexchange.com/tags/my-tag">My Tag</a>
<a href="http://wordpress.stackexchange.com/category/my-category">My Category</a>
1 Answer
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' );