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.
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 asked Sep 28, 2012 at 21:10 marpamarpa 616 bronze badges1 Answer
Reset to default 1We 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'))).' » %s', '2010-translucence' ), '<span>' . single_tag_title( '', false ) . '</span>' );