概览

如果计划移除归档页面分类或标签名称前面的 “分类:” 和 “标签:”,将该代码添加到当前使用的主题的 functions.php 文件即可显效。

代码

function my_theme_archive_title( $title ) {
    if ( is_category() ) {
        $title = single_cat_title( '', false );
    } elseif ( is_tag() ) {
        $title = single_tag_title( '', false );
    } elseif ( is_author() ) {
        $title = '<span class="vcard">' . get_the_author() . '</span>';
    } elseif ( is_post_type_archive() ) {
        $title = post_type_archive_title( '', false );
    } elseif ( is_tax() ) {
        $title = single_term_title( '', false );
    }
  
    return $title;
}
 
add_filter( 'get_the_archive_title', 'my_theme_archive_title' );

原文

https://www.wpdaxue.com/the_archive_title.html


2 条评论

李某某 · 2020年12月21日 09:49

毫无反应呐

    何星星 · 2020年12月21日 16:22

    确认代码和增加的位置是否正确。

发表回复

Avatar placeholder

您的电子邮箱地址不会被公开。 必填项已用*标注