いわゆる「あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめも…」のように、
文字数を超えた部分を、…と表示する方法。タイトルと本文2つ用意してみた。
文字数以下ならば、…と表示されないようにしている。
タイトル
<?php if(mb_strlen($post->post_title)>20) { $title= mb_substr($post->post_title,0,20) ; echo $title. ・・・ ;
} else {echo $post->post_title;}?>
本文
function.php
/*excerpt*/
function change_excerpt_mblength($length) {
return 150;
}
add_filter('excerpt_mblength', 'change_excerpt_mblength');
function new_excerpt_more($more) {
return '…';
}
add_filter('excerpt_more', 'new_excerpt_more');
表示させるphp
<?php the_excerpt(); ?>