WordPressでは記事の抜粋をする際に、
<?php the_excerpt(); ?>
か、
<?php get_the_excerpt(); ?>
と記述するのでR。
これらの違いは、ここをみると、get_the_excerpt() は文字列を返し、the_excerpt()はその文字列の開始と終了にpタグを追加しているようでR。ただし、postIDで指定する場合は、get_the_excerpt()で出来るようでR。
そこで、どちらかによって抜粋を得たとして、その文字列はdefaultではここによると、55文字になっているようでR。ただし、日本語の場合はいろいろと違うようでRが、当方のカウントではプラグイン「WP Multibyte Patch」なしの状態で、50ちょいぐらいであったのでR。
しかし、
この文字数をもう少し必要とする場合は、function.phpをいじる必要があるのでR。
ここによると、
function new_excerpt_length($length) { return 100; } add_filter( 'excerpt_length', 'new_excerpt_length');
と追加するだけでよいようでR。追加するとそうなったのでR。
その他、…の処理や、ページごと指定は、先ほどと同じく、ここに詳しく書いてあるのでR。それを参考にするとよいのでR。




この記事をシェアできます。