抜粋で表示される文字数

VWSとは フォーラム Lightning 抜粋で表示される文字数

抜粋で表示される文字数

  • このトピックには7件の返信、2人の参加者があり、最後にr-miuraにより4年、 10ヶ月前に更新されました。
8件の投稿を表示中 - 1 - 8件目 (全8件中)
  • 投稿者
    投稿
  • #16795

    r-miura
    参加者

    抜粋で表示される文字数を増やしたいので、
    functions.phpに以下を追加したのですが、表示文字数が変わりません。
    どの様にしたら良いでしょうか?

    function new_excerpt_mblength($length) {
    return 150;
    }
    add_filter(‘excerpt_mblength’, ‘new_excerpt_mblength’);

    #16797

    DRILL LANCER
    モデレーター

    「WP Multibyte Patch」はインストールされていますか?
    WordPress5.0以降は別途インストールする必要があります。

    後はコード内に全角文字が紛れ込んでいる可能性があったりします。

    function new_excerpt_mblength( $length ) {
    	return 150;
    }
    add_filter( 'excerpt_mblength', 'new_excerpt_mblength' );
    #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’);

    #16799

    DRILL LANCER
    モデレーター

    えーと、コードを掲載する際はcodeボタンを使用したほうが良いかと思われます。
    もしくはコードの部分を逆クウォート(Shift+@)で囲むのもありです。
    (上記2つの結果は同じです。)

    なぜなら、codeボタンを使用しない場合、一部の半角文字が全角文字に変更されるためです。
    特に'に変換されるのでこのあたりの検証ができなくなります。

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

    DRILL LANCER
    モデレーター

    日本語で『the_excerpt』の文字数を変える方法2パターン

    上記ページにあるwpmp-config.phpを使用する方法を試してみてください。
    もしくは併用するのも手かもしれません。

    #16810

    r-miura
    参加者

    RICK様

    ありがとうございました。
    試してみます。

    #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;

8件の投稿を表示中 - 1 - 8件目 (全8件中)
  • このトピックに返信するにはログインが必要です。