more でページトップへジャンプ

続きを読む.. でジャンプした場合、通常はページ内の more タグを挿入した箇所にジャンプするが、ページトップにジャンプするようにした。
wordpress のマニュアルページ 「続きを読む」のカスタマイズ に書いてある通りに設定した。

まずは functions.php に下記を追加

function remove_more_jump_link($link) { 
$offset = strpos($link, '#more-');
if ($offset) {
$end = strpos($link, '"',$offset);
}
if ($end) {
$link = substr_replace($link, '', $offset, $end-$offset);
}
return $link;
}
add_filter('the_content_more_link', 'remove_more_jump_link');

function remove_more_jump_link($link) { $offset = strpos($link, '#more-'); if ($offset) { $end = strpos($link, '"',$offset); } if ($end) { $link = substr_replace($link, '', $offset, $end-$offset); } return $link; } add_filter('the_content_more_link', 'remove_more_jump_link');

そして、本日からの適用になるが、投稿時に入れるタグを以下のように変更した。

<!--more |続きを読む・・・ -->

<!--more |続きを読む・・・ -->

コメントを残す

モバイルバージョンを終了