WordPress 3.1.2 「続きを読む」のカスタマイズ

WordPress 3.1.2で書いた記事の抜粋で「続きを読む」をクリックすると、moreタグの位置に移動して表示してくれるのですが、これがかえって不便に感じることがあるので、「続きを読む」をクリックしたら全文のトップを表示するようにカスタマイズしました。手順はログインして外観-テーマ編集で右側にあるテンプレートの「テーマのための関数(functions.php)」を表示させ、以下のソースを追加するだけです。
※今回はfunctions.phpの最下部に挿入しました。


}

ここに追加ソースを挿入

endif;


■追加ソース

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');


コメントする

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA


このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny