Title: 海外テーマ NewsPeperでの一覧表示時、抜粋文字数
Last modified: 2016年9月15日

---

# 海外テーマ NewsPeperでの一覧表示時、抜粋文字数

 *  [kumi_asa](https://ja.wordpress.org/support/users/kumi_asa/)
 * (@kumi_asa)
 * [10年、 10ヶ月前](https://ja.wordpress.org/support/topic/%e6%b5%b7%e5%a4%96%e3%83%86%e3%83%bc%e3%83%9e-newspeper%e3%81%a7%e3%81%ae%e4%b8%80%e8%a6%a7%e8%a1%a8%e7%a4%ba%e6%99%82%e3%80%81%e6%8a%9c%e7%b2%8b%e6%96%87%e5%ad%97%e6%95%b0/)
 * 現在、Newspeperという海外テーマを使いサイトを制作中です。
    このテーマで以下の
   問題が出ており、解決の糸口を探しています。
 * 各投稿の一覧にて本文を自動で抜粋してトップページにて表示している
    箇所があるの
   ですが、英文はしっかり設定している文字数で表示されますが、 日本語になると本文
   全てが表示されてしまいます。
 * 以下サイトのLIFESTYLEというブロックの様な感じになります。
    [http://nocomplex.org/wp/](http://nocomplex.org/wp/)
 * WP Multibyte Patchとfunctions.phpとの設定等はネットで情報が得られる物は
    ほぼ
   試しましたが、まったく上手くいきませんでした。
 * the_excerptに他のモジュールで設定された内容のものが表示されている様なのですが、
   
   知識不足で理解出来ておりません。 （文字数は管理画面で設定でき、英文はその内容
   で表示されております。）
 * おそらく該当の箇所が以下のソースになるかと思います。
 * * returns a string containing the numbers of words or chars for the content
    **
   [@param](https://ja.wordpress.org/support/users/param/) $post_content – the content
   thats need to be cut * [@param](https://ja.wordpress.org/support/users/param/)
   $limit – limit to cut * [@param](https://ja.wordpress.org/support/users/param/)
   string $show_shortcodes – if shortcodes * [@return](https://ja.wordpress.org/support/users/return/)
   string */ static function excerpt($post_content, $limit, $show_shortcodes = ”){//
   REMOVE shortscodes and tags if ($show_shortcodes == ”) { // strip_shortcodes();
   this remove all shortcodes and we don’t use it, is nor ok to remove all shortcodes
   like dropcaps // this remove the caption from images $post_content = preg_replace(“/\[
   caption(.*)\[\/caption\]/i”, ”, $post_content); // this remove the shortcodes
   but leave the text from shortcodes $post_content = preg_replace(‘`\[[^\]]*\]`‘,”,
   $post_content); }
 * $post_content = stripslashes(wp_filter_nohtml_kses($post_content));
 * /*only for problems when you need to remove links from content; not 100% bullet
   prof
    $post_content = htmlentities($post_content, null, ‘utf-8’); $post_content
   = str_replace(” “, “”, $post_content); $post_content = html_entity_decode($post_content,
   null, ‘utf-8’);
 * //$post_content = preg_replace(‘(((ht|f)tp(s?)\://){1}\S+)’,”,$post_content);//
   Radu A
    $pattern = “/[a-zA-Z]*[:\/\/]*[A-Za-z0-9\-_]+\.+[A-Za-z0-9\.\/%&=\?\-_]
   +/i”;//radu o $post_content = preg_replace($pattern,”,$post_content);*/
 * // remove the youtube link from excerpt
    //$post_content = preg_replace(‘~(?:
   http|https|)(?::\/\/|)(?:www.|)(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/
   watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[
   ^\w\-\s]))([\w\-]{11})[a-z0-9;:@?&%=+\/\$_.-]*~i’, ”, $post_content);
 * //excerpt for letters
    if (td_util::get_option(‘tds_excerpts_type’) == ‘letters’){
 *  $ret_excerpt = mb_substr($post_content, 0, $limit);
    if (mb_strlen($post_content)
   >=$limit) { $ret_excerpt = $ret_excerpt.’…’; }
 *  //excerpt for words
    } else { /*removed and moved to check this first thing 
   when reaches thsi function * if ($show_shortcodes == ”) { $post_content = preg_replace(‘`\[[
   ^\]]*\]`‘,”,$post_content); }
 *  $post_content = stripslashes(wp_filter_nohtml_kses($post_content));*/
 *  $excerpt = explode(‘ ‘, $post_content, $limit);
 *  if (count($excerpt)>=$limit) {
    array_pop($excerpt); $excerpt = implode(” “,
   $excerpt).’…’; } else { $excerpt = implode(” “,$excerpt); }
 *  $excerpt = esc_attr(strip_tags($excerpt));
 *  if (trim($excerpt) == ‘…’) {
    return ”; }
 *  $ret_excerpt = $excerpt;
    } return $ret_excerpt; }
 * もし解決のヒントをいただける様であれば
    ご回答宜しくお願い致します。

2件の返信を表示中 - 1 - 2件目 (全2件中)

 *  [nobita](https://ja.wordpress.org/support/users/nobita/)
 * (@nobita)
 * [10年、 10ヶ月前](https://ja.wordpress.org/support/topic/%e6%b5%b7%e5%a4%96%e3%83%86%e3%83%bc%e3%83%9e-newspeper%e3%81%a7%e3%81%ae%e4%b8%80%e8%a6%a7%e8%a1%a8%e7%a4%ba%e6%99%82%e3%80%81%e6%8a%9c%e7%b2%8b%e6%96%87%e5%ad%97%e6%95%b0/#post-187940)
 * こんにちは、
 * > WP Multibyte Patchとfunctions.phpとの設定等はネットで情報が得られる物は
   >  ほぼ
   > 試しましたが、まったく上手くいきませんでした。
 * 大分苦労しているのだろうと推察しますが、一言でいうと　概要表示用のカスタム関数
   が
 * 「オレオレコード」で書かれているために、一般的な概要表示のカスタマイズ方法や、
   マルチバイトパッチのコントロールが効かない状態になっています。
 * 提示いただいた概要文用の関数には、ほとんどワードプレス関数は使われていませんし、
   標準的なフィルターやアクションも実装されていません。
 * 解決方法は、制作者のみぞ知るという状態に見えますので、テーマのサポートフォーラム
   で質問をしてみるのが最善です。
 *  [GoUps](https://ja.wordpress.org/support/users/goups/)
 * (@goups)
 * [10年、 10ヶ月前](https://ja.wordpress.org/support/topic/%e6%b5%b7%e5%a4%96%e3%83%86%e3%83%bc%e3%83%9e-newspeper%e3%81%a7%e3%81%ae%e4%b8%80%e8%a6%a7%e8%a1%a8%e7%a4%ba%e6%99%82%e3%80%81%e6%8a%9c%e7%b2%8b%e6%96%87%e5%ad%97%e6%95%b0/#post-187944)
 *     ```
       static function excerpt($post_content, $limit, $show_shortcodes = '') {
          $limit = 40;//40文字で切りたい場合
       ```
   
 * のように$limitの値を関数の中で強制的に指定してみたらどうでしょう。

2件の返信を表示中 - 1 - 2件目 (全2件中)

 トピック「海外テーマ NewsPeperでの一覧表示時、抜粋文字数」には新たに返信すること
はできません。

## タグ

 * [excerpt](https://ja.wordpress.org/support/topic-tag/excerpt/)
 * [自動抜粋](https://ja.wordpress.org/support/topic-tag/%e8%87%aa%e5%8b%95%e6%8a%9c%e7%b2%8b/)
 * [Newspaper](https://ja.wordpress.org/support/topic-tag/newspaper/)

 * フォーラム: [テーマ](https://ja.wordpress.org/support/forum/themes/)
 * 2件の返信
 * 3人の参加者
 * 最後の返信者: [GoUps](https://ja.wordpress.org/support/users/goups/)
 * 最後の活動: [10年、 10ヶ月前](https://ja.wordpress.org/support/topic/%e6%b5%b7%e5%a4%96%e3%83%86%e3%83%bc%e3%83%9e-newspeper%e3%81%a7%e3%81%ae%e4%b8%80%e8%a6%a7%e8%a1%a8%e7%a4%ba%e6%99%82%e3%80%81%e6%8a%9c%e7%b2%8b%e6%96%87%e5%ad%97%e6%95%b0/#post-187944)
 * 状態: 未解決

## トピック

### 人気のトピック

### 返信がないトピック

### サポート関連ではないトピック

### 解決済みのトピック

### 未解決のトピック

### すべてのトピック
