最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

categories - How can I include custom category and tag base in template files?

programmeradmin1浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 1

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>' );
发布评论

评论列表(0)

  1. 暂无评论