SEO視点から見て、更新日の表示は重要
U3
2020/6/8
2024/11/7
大切なのは公開日ではなく、最終更新日である。
Googleの検索エンジンも、更新日の新しい情報を優遇しているという話がある。
SEOの内部施策としては、Google検索で更新日が出るようなコーディングが必要ということになります。コーダーの方は必見です。
記事の更新日をHTML5対応にして正しくGoogleに伝える方法[WordPressカスタマイズ]
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);
}
}
single.phpの編集(記事の更新日を優先して使いたい場合)
<?php if (get_mtime('c') == null) : ?>
公開日:<time class="entry-date date published" datetime="<?php the_time('c') ;?>"><?php the_time('Y年n月j日') ;?></time>
<?php endif; ?>
<?php if (get_mtime('c') != null) : ?>
公開日:<?php the_time('Y年n月j日') ;?><br>
<time class="entry-date date updated" datetime="<?php if ($mtime = get_mtime('c')) echo $mtime; ?>"><?php if ($mtime = get_mtime('Y年n月j日')) echo '最終更新日:' , $mtime; ?></time>
<?php endif; ?>

コメント
コメントはまだありません。