例如,我想从“Category:Scotland”中删除“Category:”。我尝试了以下方法:
if ( have_posts() ) : ?>
<header class="page-header">
<?php
add_filter( \'get_the_archive_title\', function ($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>\' ;
}
return $title;
});
但这也删除了“苏格兰”。我如何解决这个问题(标签和作者也是如此)?
起初的archive.php
- 位于:wp-content\\themes\\islemag\\archive.php
get_header(); ?>
<div class="container">
<div class="row">
<div class="islemag-content-left col-md-9">
<?php if ( have_posts() ) : ?>
<header class="page-header">
<?php
the_archive_title( \'<h1 class="page-title">\', \'</h1>\' );
the_archive_description( \'<div class="taxonomy-description">\', \'</div>\' );
?>
</header><!-- .page-header -->
<?php
while ( have_posts() ) : the_post();
get_template_part( \'template-parts/content\', get_post_format() );
endwhile;
the_posts_navigation();
else :
get_template_part( \'template-parts/content\', \'none\' );
endif;
?>
</div><!-- End .islemag-content-left -->
<?php get_sidebar(); ?>
</div><!-- End .row -->