カテゴリータイトルから「カテゴリー別アーカイブ」の表記を消す方法

カテゴリータイトルから「カテゴリー別アーカイブ」の表記を消す方法

WordPressのデフォルトテーマを使用していると、カテゴリーページのタイトルは「カテゴリー別アーカイブ: カテゴリー名」となってしまいます。このうち「カテゴリ別アーカイブ」の表記だけを消して「カテゴリー名」のみを表示させてみます。

目次

twentyfourteen

twentyfourteen-before

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
get_header(); ?>
 
    <section id="primary" class="content-area">
        <div id="content" class="site-content" role="main">
 
            <?php if ( have_posts() ) : ?>
 
            <header class="archive-header">
                <h1 class="archive-title"><?php printf( __( 'Category Archives: %s', 'twentyfourteen' ), single_cat_title( '', false ) ); ?></h1>
 
                <?php
                    // Show an optional term description.
                    $term_description = term_description();
                    if ( ! empty( $term_description ) ) :
                        printf( '<div class="taxonomy-description">%s</div>', $term_description );
                    endif;
                ?>
            </header>

9行目のコードを下記に変更します。

1
<h1 class="archive-title"><?php single_cat_title(); ?></h1>
twentyfourteen-after

「カテゴリ別アーカイブ」の表記が消えて「カテゴリー名」のみとなりました。

twentytwelve

twentytwelve-before

1
2
3
4
5
6
7
8
9
10
11
12
13
get_header(); ?>
 
    <section id="primary" class="site-content">
        <div id="content" role="main">
 
        <?php if ( have_posts() ) : ?>
            <header class="archive-header">
                <h1 class="archive-title"><?php printf( __( 'Category Archives: %s', 'twentytwelve' ), '<span>' . single_cat_title( '', false ) . '</span>' ); ?></h1>
 
            <?php if ( category_description() ) : // Show an optional category description ?>
                <div class="archive-meta"><?php echo category_description(); ?></div>
            <?php endif; ?>
            </header><!-- .archive-header -->

8行目のコードを下記に変更します。

1
<h1 class="archive-title"><span><?php single_cat_title(); ?></span></h1>
twentytwelve-after

こちらも「カテゴリー名」のみとなってスッキリしました。

このエントリーをはてなブックマークに追加

コメントを残す

頂いたコメントは一読した後表示させて頂いております。
反映まで数日かかる場合もございますがご了承下さい。