Php 向WordPress主题文件添加类别标题

Php 向WordPress主题文件添加类别标题,php,wordpress,wordpress-theming,Php,Wordpress,Wordpress Theming,在自定义WordPress主题中的我的archives.php文件中,我有以下代码: <div class="page-title"> <?php if ( is_day() ) : printf( __( 'Daily Archives: %s', 'sturd' ), '<span>' . get_the_date() . '</span>' );

在自定义WordPress主题中的我的archives.php文件中,我有以下代码:

<div class="page-title">
<?php
                if ( is_day() ) :
                    printf( __( 'Daily Archives: %s', 'sturd' ),     '<span>' . get_the_date() . '</span>' );
                elseif ( is_month() ) :
                    printf( __( 'Monthly Archives: %s', 'sturd' ), '<span>' . get_the_date( _x( 'F Y', 'monthly archives date format', 'sturd' ) ) . '</span>' );
                elseif ( is_year() ) :
                    printf( __( 'Yearly Archives: %s', 'sturd' ), '<span>' . get_the_date( _x( 'Y', 'yearly archives date format', 'sturd' ) ) . '</span>' );
                else :
                    _e( 'Archives', 'sturd' );
                endif;
            ?>
</div>

我希望有另一个语句,以便如果这是一个类别页面,它只显示页面标题div中的类别标题,而不只是单词Archives(正如它目前所做的那样)

我希望这是张贴在正确的部分

提前谢谢


Sam

首先,我建议你加入WP。我通常建议使用单独的category.php模板文件来显示类别,并使用来显示类别名称


如果您想使用main archive.php模板,您可以添加一个子句,然后使用来获取名称。

以后,您可能更愿意将与WP相关的问题发布在。