Wordpress > 抜粋の文字数とmore文字の変更(マルチバイト)

1. WP Multibyte Patch をインストールする

2. wpmp-config-sample-ja.php を wpmp-config.php に変名して以下配置。(WP_CONTENT_DIR を変更している場合はその中に)
/wp-content/wpmp-config.php

3. function.phpに以下のコード
// 抜粋の文字数
function my_excerpt_length($length) {
     return 50;
}
add_filter('excerpt_mblength', 'my_excerpt_length');
 
 
// more の変更
function my_excerpt_more($more) {
    return '.....';
}
add_filter('excerpt_more', 'my_excerpt_more');
 
 
// more をリンクにする場合はこっち
function my_excerpt_more($post) {
    return '<a href="'. get_permalink($post->ID) . '">' . '...続きを読む' . '</a>';   
}   
add_filter('excerpt_more', 'my_excerpt_more');
 
最終更新:2013年03月08日 10:36