Written by Anonymous
//seo.php
} elseif (is_category()) {
$cat_id = get_query_var('cat');
$cat_name = $title['title'];
if ($cat_id && get_category_title($cat_id)) {
$cat_name = get_category_title($cat_id);
}
$title['title'] = $cat_name;
$title['site'] = '';
switch (get_category_page_title_format()) {
case 'category_sitename':
$title['title'] = $cat_name;
$title['site'] = $site_name;
break;
case 'sitename_category':
$title['title'] = $site_name;
$title['site'] = $cat_name;
break;
}
} elseif (is_tag()) {
$tag_id = get_query_var('tag_id');
$tag_name = $title['title'];
if ($tag_id && get_tag_title($tag_id)) {
$tag_name = get_tag_title($tag_id);
}
$title['title'] = $tag_name;
$title['site'] = '';
switch (get_category_page_title_format()) {//※カテゴリーと共通?
case 'category_sitename':
$title['title'] = $tag_name;
$title['site'] = $site_name;
break;
case 'sitename_category':
$title['title'] = $site_name;
$title['site'] = $tag_name;
break;
}
} elseif (is_404()) {
...
//※タグ・タクソノミーページのindex or noindexはどう扱う?
function is_noindex_page(){
return (is_archive() && !is_category() && !is_tag() && !is_tax() && is_other_archive_page_noindex()) || //アーカイブページはインデックスに含めない
( is_tax() && is_tag_page_noindex() ) || //※関数を分ける?
( is_tag() && is_paged() && is_tag_page_noindex() ) || //タグページをインデックスしたい場合はこの行を削除
( is_category() && is_paged() && is_paged_category_page_noindex() ) || //ページの2ページ目以降はインデックスに含めない(似たような内容の薄いコンテンツの除外)
(is_attachment() && is_attachment_page_noindex()) || //添付ファイルページも含めない
is_search() || //検索結果ページはインデックスに含めない
is_404(); //404ページはインデックスに含めない
}
...
//タグメタディスクリプション用の説明文を取得
if ( !function_exists( 'get_tag_meta_description' ) ):
function get_tag_meta_description($tag = null){
//タグ設定ページのディスクリプションを取得
$tag_desc = trim( strip_tags( get_tag_description() ) );
if ( $tag_desc ) {//ディスクリプションが設定されている場合
return htmlspecialchars($tag_desc);
}
//タグ説明文を取得
$tag_desc = trim( strip_tags( tag_description() ) );
if ( $tag_desc ) {//タグ設定に説明がある場合はそれを返す
return htmlspecialchars($tag_desc);
}
//タグ本文から抜粋文を作成
$tag_desc = trim( strip_tags( get_content_excerpt(get_tag_content(), 160) ) );
if ( $tag_desc ) {//タグ設定に説明がある場合はそれを返す
return htmlspecialchars($tag_desc);
}
//タグ名から作成
if ($tag) {
$tag_name = $tag->name;
} else {
$tag_name = single_tag_title('', false);
}
$tag_desc = sprintf( __( '「%s」の記事一覧です。', THEME_NAME ), $tag_name );
return htmlspecialchars($tag_desc);
}
endif;
...
//タグキーワード用のワードを取得
if ( !function_exists( 'get_tag_meta_keywords' ) ):
function get_tag_meta_keywords(){
if ($keywords = get_tag_keywords()) {
return $keywords;
} else {
return single_tag_title('', false);
}
}
endif;
...
function get_meta_description_text(){
$description = null;
if (is_front_page() && get_front_page_meta_description()) {
$description = get_front_page_meta_description();
} elseif (is_singular() && is_meta_description_to_singular()) {
$description = get_the_meta_description();
} elseif (is_category() && is_meta_description_to_category()) {
$description = get_category_meta_description();
} elseif (is_tag() && is_meta_description_to_category()) {//※カテゴリーページのメタタグ設定と共通?
$description = get_tag_meta_description();
}
return apply_filters('meta_description_text', $description);
}
...
function get_meta_keywords_text(){
$keywords = null;
//var_dump(get_the_meta_keywords());
if (is_front_page() && get_front_page_meta_keywords()) {
$keywords = get_front_page_meta_keywords();
} elseif (is_singular() && is_meta_keywords_to_singular()) {
$keywords = get_the_meta_keywords();
} elseif (is_category() && is_meta_keywords_to_category()) {
$keywords = get_category_meta_keywords();
} elseif (is_tag() && is_meta_keywords_to_category()) {//※カテゴリーページのメタタグ設定と共通?
$keywords = get_tag_meta_keywords();
}
return apply_filters('meta_keywords_text', $keywords);
}