抜粋で表示される文字数
抜粋で表示される文字数
- 
		投稿者投稿
- 
		
			
				
2019年6月11日 12:07 AM #16795
 r-miura参加者抜粋で表示される文字数を増やしたいので、 
 functions.phpに以下を追加したのですが、表示文字数が変わりません。
 どの様にしたら良いでしょうか?function new_excerpt_mblength($length) { 
 return 150;
 }
 add_filter(‘excerpt_mblength’, ‘new_excerpt_mblength’);2019年6月11日 5:47 AM #16797
 DRILL LANCERモデレーター「WP Multibyte Patch」はインストールされていますか? 
 WordPress5.0以降は別途インストールする必要があります。後はコード内に全角文字が紛れ込んでいる可能性があったりします。 function new_excerpt_mblength( $length ) { return 150; } add_filter( 'excerpt_mblength', 'new_excerpt_mblength' );2019年6月11日 10:49 AM #16798
 r-miura参加者RICK様 WP Multibyte Patchはインストールされ有効化います。 
 functions.php の全文の内容は下記の通りです。全角は含まれていませんでした。
 子テーマの中で設定しています。<?php 
 //
 // Recommended way to include parent theme styles.
 // (Please see http://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme)
 //
 add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’ );
 function theme_enqueue_styles() {
 wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ );
 wp_enqueue_style( ‘child-style’,
 get_stylesheet_directory_uri() . ‘/style.css’,
 array(‘parent-style’)
 );
 }
 //
 // Your code goes below
 //
 function new_excerpt_mblength($length) { return 250;}
 add_filter(‘excerpt_mblength’,’new_excerpt_mblength’);2019年6月11日 12:51 PM #16799
 DRILL LANCERモデレーターえーと、コードを掲載する際は codeボタンを使用したほうが良いかと思われます。
 もしくはコードの部分を逆クウォート(Shift+@)で囲むのもありです。
 (上記2つの結果は同じです。)なぜなら、 codeボタンを使用しない場合、一部の半角文字が全角文字に変更されるためです。
 特に'が‘に変換されるのでこのあたりの検証ができなくなります。2019年6月11日 1:49 PM #16802
 r-miura参加者RICK様 
 ご指摘ありがとうございます。
 functions.php のソースをcodeで囲んでみました。<?php // // Recommended way to include parent theme styles. // (Please see http://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme) // add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); function theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array('parent-style') ); } // // Your code goes below // function new_excerpt_mblength($length) { return 250;} add_filter('excerpt_mblength','new_excerpt_mblength');2019年6月11日 2:03 PM #16805
 DRILL LANCERモデレーター上記ページにある wpmp-config.phpを使用する方法を試してみてください。
 もしくは併用するのも手かもしれません。2019年6月11日 2:51 PM #16810
 r-miura参加者RICK様 ありがとうございました。 
 試してみます。2019年6月12日 11:33 AM #16840
 r-miura参加者RICK様 お教えいただいたページの説明で、解決できると思い、実際にテストしていなかったのですが、 
 下記の設定をしてみましたが、抜粋の文字数は変化がありませんでした。
 WP Multibyte Patchとの関係もあり、複雑なようなので、本件はこれでクローズで結構です。
 ありがとうございました。『WP Multibyte Patch』のフォルダで『wpmp-config-sample.php』というファイルを探します。パスは以下。 
 (WordPressインストールフォルダ)/wp-content/plugins/wp-multibyte-patch/
 そのファイルを『wpmp-config.php』という名称に変更して『wp-content』フォルダ内に保存します。
 wpmp-config.phpの中の設定
 `$wpmp_conf[‘excerpt_mblength’] = 260;
- 
		投稿者投稿
- このトピックに返信するにはログインが必要です。

