サポート » 使い方全般 » the_excerpt();の文字数を変更したい

  • 解決済 honeycreate

    (@honeycreate)


    SKT Girlie Proというテーマを使用しています。
    トップページに記事を載せるのですが、全文が表示されてしまいます。
    英文だと制御されてますが、日本文の文字数制限が制御できてません。

    プラグインのWP Multibyte Patchは有効化しています。

    子テーマフォルダ内のfunction.phpに

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

    としてみましたが変わりません。

    親テーマのfunction.phpの中に

    function excerpt($num) {
    $limit = $num+1;
    $excerpt = explode(‘ ‘, get_the_excerpt(), $limit);
    array_pop($excerpt);
    $excerpt = implode(” “,$excerpt).”…”;
    echo $excerpt;
    }

    とあったので、この当たりが制御する部分かなと思ったのですが
    どうしたらいいのかわかりません。

    わかる方教えてください。

    どうぞよろしくお願いします。

3件の返信を表示中 - 1 - 3件目 (全3件中)
  • トピック投稿者 honeycreate

    (@honeycreate)

    追記です

    incフォルダの中にある
    custom-functions.phpというファイルの中に
    以下の記述を見つけました。

    function latestpostsoutput_func( $atts ){
       extract( shortcode_atts( array(
    		'show' => '',
    	), $atts ) );
    	$postoutput = '';
    	wp_reset_query();
    	$n = 0;
    	query_posts(  array( 'posts_per_page'=>$show, 'post__not_in' => get_option('sticky_posts') )  );
    	if ( have_posts() ) :
    		while ( have_posts() ) : the_post();
    			$n++;
    			if( $n%3==0 )  $nomgn = 'last';	else $nomgn = ' ';
    			if ( has_post_thumbnail()) {
    				$large_imgSrc = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large');
    				$imgUrl = $large_imgSrc[0];
    			}else{
    				$imgUrl = get_template_directory_uri().'/images/img_404.png';
    			}
    			$postoutput .= '<div class="news-box '.$nomgn.'">
    								<div class="news-thumb">
    									<a href="'.get_the_permalink().'"><img src="'.$imgUrl.'" alt="" /></a>
    								</div>
    								<div class="news">
    									<a href="'.get_permalink().'"><h6>'.get_the_title().'</h6></a>
    									<div class="date-news">
    										<span><i class="fa fa-calendar"></i> Posted On <a href="'.get_day_link().'">'.get_the_time('d-M-Y').'</a></span>
    
    									</div>
    									 '.content(50).'
    									 <a href="'.get_permalink().'" class="linkreadmore">Read More</a>
    								</div>
                            </div>';
    						$postoutput .= ''.(($n%3==0) ? '<div class="clear"></div>' : '');
    		endwhile;
    	endif;
    	wp_reset_query();
    	return $postoutput;
    }
    add_shortcode( 'latestposts', 'latestpostsoutput_func' );

    同じようにincフォルダを子テーマ内に作り
    custom-functions.phpをコピペして複製して
    変更してみましたが変わりません。

    プラグインShow Current Templateで見てみても、
    子テーマ内のcustom-functions.phpは読み込んでないようです。
    親テーマのcustom-functions.phpは読み込まれてました。

    同じファイル名だと子テーマの方が優先されるかと思ったのですが
    やり方が違うのでしょうか?

    どうぞよろしくお願いします。

    こんにちは

    SKT Girlie Proは、有償テーマなので、このフォーラムでは扱わないことになっています。

    ただ、lite版は、ディレクトリにホストされているので、light版に置き換えて考えてみました。 プロ版に適用できるかわかりません。

    functions.phpに、skt_girlie_content()という関数があります。

    index.phpで、この関数が使われていて、

    <?php echo skt_girlie_content(27); ?>

    という風に、ダイレクトに27文字が指定されています。

    この関数は、プラグアブルに書かれてないので、

    検証はしてませんが、
    この関数を、チャイルドテーマfunctions.phpにコピー リネームして、

    index.phpの関数部分を、リネームした関数に置き換えてやるといった事になると思います。
    (チャイルドテーマユーザーには、大変厄介な事ですが、、、)

    といった事になると思います。

    同じようにincフォルダを子テーマ内に作り
    custom-functions.phpをコピペして複製して
    変更してみましたが変わりません。

    残念ながら、このテーマでは(デフォルトもそうですが)functions.phpでインクルードするファイルは、チャイルドテーマでは動かないと思います。(proの作りは解かりませんが、)

    理由は、

    /**
     * Implement the Custom Header feature.
     */
    require get_template_directory() . '/inc/custom-header.php';

    単に、テンプレートディレクトリのファイルをインクルードするだけで、チャイルドテーマでの同名ファイルの検索を行う手順が抜けているためです。(というか、そこまで考えていないんだと思います)

    トピック投稿者 honeycreate

    (@honeycreate)

    有料のテーマなのにお答えいただきありがとうございました。
    またお返事が遅くなり、大変失礼しました。

    functionが絡むファイルは難しいんですね。。

    結局moreタグで対処することとしました。

    細かい部分まで設定したかったらやはり一から作らないとですね。

    ありがとうございました!!

3件の返信を表示中 - 1 - 3件目 (全3件中)
  • トピック「the_excerpt();の文字数を変更したい」には新たに返信することはできません。