//function.php function get_archive_chapter_title(){ $chapter_title = null; if( is_category() ) {//カテゴリページの場合 $cat_id = get_query_var('cat'); $icon_font = '<span class="fa fa-folder-open"></span>'; if ($cat_id && get_category_title($cat_id)) { $chapter_title .= $icon_font.get_category_title($cat_id); } else { $chapter_title .= single_cat_title( $icon_font, false ); } } elseif( is_tag() ) {//タグページの場合 $tag_id = get_query_var('tag_id'); $icon_font = '<span class="fa fa-tags"></span>'; if ($tag_id && get_tag_title($tag_id)) { $chapter_title .= $icon_font.get_tag_title($tag_id); } else { $chapter_title .= single_tag_title( $icon_font, false ); } } elseif( is_tax() ) {//タクソノミページの場合 $chapter_title .= single_term_title( '', false ); } elseif( is_search() ) {//検索結果 $search_query = trim(strip_tags(get_search_query())); if (empty($search_query)) { $search_query = __( 'キーワード指定なし', THEME_NAME ); } $chapter_title .= '<span class="fa fa-search"></span>"'.$search_query.'"'; } elseif (is_day()) { //年月日のフォーマットを取得 $chapter_title .= '<span class="fa fa-calendar"></span>'.get_the_time('Y-m-d'); } elseif (is_month()) { //年と月のフォーマットを取得 $chapter_title .= '<span class="fa fa-calendar"></span>'.get_the_time('Y-m'); } elseif (is_year()) { //年のフォーマットを取得 $chapter_title .= '<span class="fa fa-calendar"></span>'.get_the_time('Y'); } elseif (is_author()) {//著書ページの場合 $chapter_title .= '<span class="fa fa-user"></span>'.esc_html(get_queried_object()->display_name); } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { $chapter_title .= 'Archives'; } else { $chapter_title .= 'Archives'; } return $chapter_title; }