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

How can I include custom category and tag base names in the category and tag template files?Specifically, I'd lik

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>' );

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745641995a4637746.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信