1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
//--------------------------------------------------------------------------- // タイトルの表示する関数 //--------------------------------------------------------------------------- $subpage_title = "ここにサブページタイトル"; if ( ! function_exists( 'title_keni' ) ) { function title_keni( $blogname = true, $sep = " | " ) { echo get_title_keni(); } } if ( ! function_exists( 'get_title_keni' ) ) { function get_title_keni( $blogname = true, $sep = " | " ) { global $subpage_title; $title = ""; if ( is_front_page() ) { $title = ( trim( the_keni( 'top_title' ) ) != "" ) ? trim( the_keni( 'top_title' ) ) : trim( get_bloginfo( 'name' ) ); } elseif ( is_home() ) { // TODO 解読する $post_page = get_option( 'page_for_posts' ); if ( ! empty( $post_page ) && $post_page > 0 ) { $top_page_data = get_post( $post_page ); $title = $top_page_data->post_title; } else { if ( ( get_option( 'page_for_posts' ) > 0 ) && ( get_the_ID() != get_option( 'page_on_front' ) ) ) { $title = trim( get_the_title( 'name' ) ); } else { $title = trim( get_bloginfo( 'name' ) ); } } if ( is_home() && get_query_var( 'paged' ) > 1 ) { $title = sprintf( __( 'Archive List for %s', 'keni' ), $title ); } } elseif ( is_singular() ) { $title = trim( get_the_title() ); $this_page = pageNumber(); if ( $this_page['now_page'] > 1 ) { $title .= "(" . $this_page['now_page'] . "/" . $this_page['max_pages'] . __( 'Pages', 'keni' ) . ")"; } } elseif ( is_category() || is_tag() ) { $title = get_archive_title_keni( "n" ); } elseif ( is_day() ) { $title = sprintf( __( 'Archive List for %s', 'keni' ), get_the_time( __( 'F j, Y', 'keni' ) ) ); } elseif ( is_month() ) { $title = sprintf( __( 'Archive List for %s', 'keni' ), get_the_time( __( 'F Y', 'keni' ) ) ); } elseif ( is_year() ) { $title = sprintf( __( 'Archive List for %s', 'keni' ), get_the_time( __( 'Y', 'keni' ) ) ); } elseif ( is_author() ) { if ( have_posts() ): while ( have_posts() ): the_post(); $title = get_the_author_meta( 'display_name' ) . sprintf( __( 'Archive List for authors', 'keni' ) ); endwhile; wp_reset_query(); endif; } elseif ( is_post_type_archive() ) { $title = wp_title( '', false, 'right' ); } elseif ( is_archive() ) { $title = sprintf( __( 'Archive List for blog', 'keni' ) ); } elseif ( is_search() ) { $title = sprintf( __( 'Search Result for %s', 'keni' ), get_search_query() ); } elseif ( is_404() ) { $title = sprintf( __( 'Sorry, but you are looking for something that isn’t here.', 'keni' ) ); } else { $title = wp_title( '', false, 'right' ); } if ( $title == "" ) { $title = get_bloginfo( 'name' ); } if ( get_query_var( 'paged' ) > 1 ) { $title .= show_page_number(); } if ( is_page() || is_single() ) { if ( ! is_front_page() && the_keni( 'view_site_title' ) != "n" && ( ( ( get_post_meta( get_the_ID(), "title_view", true ) ) == null ) || ( get_post_meta( get_the_ID(), "title_view", true ) == "y" ) ) ) { $title .= $sep . $subpage_title; } } elseif ( ( ! is_front_page() && ! is_home() ) && the_keni( 'view_site_title' ) != "n" ) { $title .= $sep . $subpage_title; } wp_reset_query(); return esc_html( $title ); } } |