Written by Anonymous
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" aria-hidden="true"></span>'; if ($cat_id && get_the_category_title($cat_id)) { $chapter_title .= $icon_font.get_the_category_title($cat_id); } else { $chapter_title .= single_cat_title( $icon_font, false ); } } elseif( is_tag() ) {//タグページの場合 $tag_id = get_queried_object_id(); $icon_font = '<span class="fa fa-tags" aria-hidden="true"></span>'; if ($tag_id && get_the_tag_title($tag_id)) { $chapter_title .= $icon_font.get_the_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" aria-hidden="true"></span>"'.$search_query.'"'; } elseif (is_day()) { //年月日のフォーマットを取得 $chapter_title .= '<span class="fa fa-calendar" aria-hidden="true"></span>'.get_the_time('Y-m-d'); } elseif (is_month()) { //年と月のフォーマットを取得 $chapter_title .= '<span class="fa fa-calendar" aria-hidden="true"></span>'.get_the_time('Y-m'); } elseif (is_year()) { //年のフォーマットを取得 $chapter_title .= '<span class="fa fa-calendar" aria-hidden="true"></span>'.get_the_time('Y'); } elseif (is_author()) {//著書ページの場合 $chapter_title .= '<span class="fa fa-user" aria-hidden="true"></span>'.esc_html(get_the_author_meta( 'display_name', $author )); } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { $chapter_title .= 'Archives'; } else { $chapter_title .= 'News'; } return apply_filters('get_archive_chapter_title', $chapter_title); } endif;