如何在类别和标记模板文件中包括自定义类别和标记基名称?具体来说,我想在分类和标签页的页面标题中包括自定义类别和标签名称。
例如,如果站点管理转到Settings > Permalink并指定:分类基=位置标记基=软件
我希望类别页面标题为: Location > single_cat_title
我希望标签页的标题是:软件> single_tag_title
我找不到显示这个的模板标签。
发布于 2012-10-16 16:14:35
我们能够使用以下方法获得自定义类别和标记基名称:
get_option('category_base', 'Categories')
get_option('tag_base', 'Tags') 我们将这些函数封装在ucword()中,以便将基本名称大写,并将"_“替换为"":
ucwords(str_replace('_',' ',get_option('category_base', 'Categories'))
ucwords(str_replace('_',' ',get_option('tag_base', 'Tags'))最后,我们用本地化代码包装了所有这些,并添加了一个cat/tag标题:
printf( __( ucwords(str_replace('_',' ',get_option('tag_base', 'Tags'))).' » %s', '2010-translucence' ), '<span>' . single_tag_title( '', false ) . '</span>' );https://wordpress.stackexchange.com/questions/66600
复制相似问题