このお盆休みで過去のブログ記事を見直そうと思い「トライアスロンオンライン」の記事のタイトルや一部加筆修正を行った。
せっかく加筆修正を行ったのだからその情報を Google に上手く伝え、検索ツールの期間指定をされても表示されるようにならないか?と考え Google で調べた所、
「記事の最終更新日を表示する方法 HTML5対応版」という記事をみつけた。こちらのサイトで加筆修正を行った記事「自分のサイトがツイッターにスパム認定されてしまった時の対策」
を Google で検索し、期間指定をしてみた所しっかりと検索結果にあらわれたので、「トライアスロンオンライン」さっそく試させて頂く事にした。
使っているテーマの functions.php に
/*
get_the_modified_time()の結果がget_the_time()より古い場合はget_the_time()を返す。
同じ場合はnullをかえす。
それ以外はget_the_modified_time()をかえす。
*/
function get_mtime($format) {
$mtime = get_the_modified_time('Ymd');
$ptime = get_the_time('Ymd');
if ($ptime > $mtime) {
return get_the_time($format);
} elseif ($ptime === $mtime) {
return null;
} else {
return get_the_modified_time($format);
}
}
※http://www.seotemplate.biz/blog/wordpress-tips/4019/ より引用
を記述
single.php の日付部分を
公開日:<time class="entry-date" datetime="<?php the_time('c') ;?>"><?php the_time('Y年m月d日') ;?></time><br>
<?php if ($mtime = get_mtime('Y年m月d日')) echo '最終更新日:' , $mtime; ?>
に改変。オリジナルは月[n] 日[j] だったが、月[m] 日[d] にして記述した。
今後見直した記事は「サイズ超過料金無料のバイクポーターpro (BIKEPORTER PRO) にバイクを詰めてみる。」のように表示される。後は Google が拾ってくれれば OK である。
「ANKARE IIDX」さんに感謝。
このブログにも実装しました。
投稿 by EC All Stars.



コメント