この件は、ver1.6.2で修正されてます。
(投稿ラベルがタイトルタグに入ります)
(投稿一覧用固定ページタイトルを使いたい場合は、以下参考に)
newタイプのbizvektorがリリースされてから、この症状が出るんだと思います。(旧タイプなら正常だったはず)
設定手順通り、TOPページとブログ(投稿)一覧ページを設定すると、
TOPページのタイトルタグ = テーマオプションで設定した「トップページの<title>タグ」。記入がなければ「サイトタイトル」
になります。
で、ブログ一覧ページ(固定ページ)は、”ブログ一覧|サイトタイトル”になるかと思いきや、TOPページのタイトルタグと同じ。。。
ウェブマスターツールで、「重複してますよ?」って注意されてました^^;(2ヶ月ほど気づかずw)
bizvektorのデモ・サンプルサイトでもこの症状が出てます。
改善してくれると期待してますが、本日、日曜日なので、もしフォーラムでお返事してくれるとしても早くて明日。
原因は、inc/themeoptions.phpで、
1 2 3 4 5 6 7 8 |
if (is_home() || is_page('home') || is_front_page()) { if (isset($options['topTitle']) && $options['topTitle']) { $headTitle = $options['topTitle']; } else { $headTitle = get_bloginfo('name'); } |
とTOPページ(is_front_page)と投稿トップ(is_home)が同じタイトル処理になってるから。
ということで、is_home() を別処理すれば解消するんだけど、さて、さて。。。
対処するには、themeoptions.phpをイジるか、子テーマfunctions.phpでフィルター外して付け直すか。
うーん・・・(;´д`) 面倒だけど子テーマ
ってことで、子テーマfunctions.phpに追加!
ブログトップ(ブログ一覧)で使用している固定ページタイトルがタイトルタグに入ります。
(間違わないように子テーマはNEATにしてるだけなので、スキンが違うのは気にしないでw)
注意:子テーマのfunctions.phpに追加してください
テーマを読み込んだ後、remove_filterで元のgetHeadTitleを外して付け直し。is_home()の処理を変更。後の中身は元のまま。
↑ bizvektorはフィルターフックがありました^^;
なので、修正<(_ _)> is_home()以外にも変えたい部分があったら、ご自由に
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 98 99 100 101 102 |
add_filter('titleCustom','myheadtitle'); function myheadtitle($headTitle) { $options = biz_vektor_get_theme_options(); global $wp_query; $post = $wp_query->get_queried_object(); if (is_home()) { $post_id = $post->ID; $headTitle = get_the_title($post_id)." | ".get_bloginfo('name'); } else if (is_page('home') || is_front_page()) { if (isset($options['topTitle']) && $options['topTitle']) { $headTitle = $options['topTitle']; } else { $headTitle = get_bloginfo('name'); } // Author } else if (is_author()) { $userObj = get_queried_object(); $headTitle = esc_html($userObj->display_name)." | ".get_bloginfo('name'); // Page } else if (is_page()) { // Sub Pages if ( $post->post_parent ) { if($post->ancestors){ foreach($post->ancestors as $post_anc_id){ $post_id = $post_anc_id; } } else { $post_id = $post->ID; } $headTitle = get_the_title()." | ".get_the_title($post_id)." | ".get_bloginfo('name'); // Not Sub Pages } else { $headTitle = get_the_title()." | ".get_bloginfo('name'); } // Info } else if (get_post_type() === 'info') { // Single if (is_single()) { $taxo_catelist = get_the_term_list_nolink( $post->ID, 'info-cat', '', ',', '' ); if (!empty($taxo_catelist)) : $headTitle = get_the_title()." | ".$taxo_catelist." | ".get_bloginfo('name'); else : $headTitle = get_the_title()." | ".get_bloginfo('name'); endif; // Info category } else if (is_tax()){ $headTitle = single_cat_title('',false)." | ".get_bloginfo('name'); // Info crchive } else if (is_archive()) { if ( is_year()) { $headTitle = sprintf( __( 'Yearly Archives: %s', 'biz-vektor' ), get_the_date( _x( 'Y', 'yearly archives date format', 'biz-vektor' ) ) ); } if ( is_month()) { $headTitle = sprintf( __( 'Monthly Archives: %s', 'biz-vektor' ), get_the_date( _x( 'F Y', 'monthly archives date format', 'biz-vektor' ) ) ); } else { $headTitle = esc_html(bizVektorOptions('infoLabelName')); } $headTitle .= " | ".get_bloginfo('name'); } // Single } else if (is_single()) { // $category = get_the_category(); // if (!empty($category)) : // $headTitle = get_the_title()." | ".$category[0]->cat_name." | ".get_bloginfo('name'); // else : $headTitle = get_the_title()." | ".get_bloginfo('name'); // endif; // Category } else if (is_category()) { $headTitle = single_cat_title('',false)." | ".get_bloginfo('name'); // Tag } else if (is_tag()) { $headTitle = single_tag_title('',false)." | ".get_bloginfo('name'); // Archive } else if (is_archive()) { if (is_month()){ $headTitle = sprintf( __( 'Monthly Archives: %s', 'biz-vektor' ), get_the_date( _x( 'F Y', 'monthly archives date format', 'biz-vektor' ) ) ); } else if (is_year()){ $headTitle = sprintf( __( 'Yearly Archives: %s', 'biz-vektor' ), get_the_date( _x( 'Y', 'yearly archives date format', 'biz-vektor' ) ) ); } else if (is_tax()){ $headTitle = single_term_title('',false); } else if (!is_day() || !is_tax()){ global $wp_query; $postTypeName = esc_html($wp_query->queried_object->labels->name); $headTitle = $postTypeName; } $headTitle .= " | ".get_bloginfo('name'); // Search } else if (is_search()) { $headTitle = sprintf(__('Search Results for : %s', 'biz-vektor'),get_search_query())." | ".get_bloginfo('name'); //Other } else { $headTitle = get_bloginfo('name'); } global $paged; if ( $paged != '0' ){ $headTitle = '['.sprintf(__('Page of %s', 'biz-vektor' ),$paged).'] '.$headTitle; } return esc_html($headTitle); } |
ついでに、twenty系のタイトルタグは、functions.phpに記述されています。
function twentyfourteen_wp_title( $title, $sep )
の部分です。TOPページでキャッチフレーズが付くとか、なにげに迷惑なケースもあるかと思いますw
そんな時に、チョチョイと使えるかも^^
twenty系(twenty○○○部分はテーマに合わせて)
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 |
add_action( 'after_setup_theme', 'myheadtitle' ); function myheadtitle( $title, $sep ) { remove_filter( 'wp_title', 'twentyfourteen_wp_title', 10, 2); /* 処理をごにょごにょ ↓ はデフォのまま*/ global $paged, $page; if ( is_feed() ) { return $title; } // Add the site name. $title .= get_bloginfo( 'name', 'display' ); // Add the site description for the home/front page. $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description && ( is_home() || is_front_page() ) ) { $title = "$title $sep $site_description"; } // Add a page number if necessary. if ( $paged >= 2 || $page >= 2 ) { $title = "$title $sep " . sprintf( __( 'Page %s', 'twentyfourteen' ), max( $paged, $page ) ); } return $title; } add_filter( 'wp_title', 'myheadtitle', 10, 2 ); |
追記:remove_filterしなくても、myheadtitleの優先順位を10より小さい数字にすれば大丈夫みたいです