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.

How can I include custom category and tag base names in the category and tag template files? Specifically, I'd like to include in the page title of category and tag pages the custom category and tag names.

For example, if a site admin goes to Settings > Permalink and specifies: category base = location tag base = software

I would like the category page title to be: Location > single_cat_title

I would like the tag page title to be: Software > single_tag_title

I couldn't find a template tag that display this.

share|improve this question
add comment

1 Answer

We were able to get custom category and tag base names using:

get_option('category_base', 'Categories')
get_option('tag_base', 'Tags') 

We wrapped these functions in ucwords() in order to capitalize the base name and replaced "_" with "":

ucwords(str_replace('_',' ',get_option('category_base', 'Categories'))
ucwords(str_replace('_',' ',get_option('tag_base', 'Tags'))

Finally we wrapped all this with the code for localization and added the single cat/tag title:

printf( __( ucwords(str_replace('_',' ',get_option('tag_base', 'Tags'))).' &raquo; %s', '2010-translucence' ), '<span>' . single_tag_title( '', false ) . '</span>' );
share|improve this answer
add comment

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.