Title: luvjapanの返信 - page 2 | WordPress.org 日本語

---

# luvjapan

  [  ](https://ja.wordpress.org/support/users/luvjapan/)

 *   [プロフィール](https://ja.wordpress.org/support/users/luvjapan/)
 *   [作成したトピック](https://ja.wordpress.org/support/users/luvjapan/topics/)
 *   [作成した返信](https://ja.wordpress.org/support/users/luvjapan/replies/)
 *   [返信したトピック](https://ja.wordpress.org/support/users/luvjapan/replied-to/)
 *   [エンゲージメント](https://ja.wordpress.org/support/users/luvjapan/engagements/)
 *   [お気に入り](https://ja.wordpress.org/support/users/luvjapan/favorites/)

 返信を検索

## フォーラムへの返信

9件の返信を表示中 - 16 - 24件目 (全24件中)

[←](https://ja.wordpress.org/support/users/luvjapan/replies/?output_format=md) [1](https://ja.wordpress.org/support/users/luvjapan/replies/?output_format=md)
2

 *   フォーラム: [バグ報告と提案](https://ja.wordpress.org/support/forum/feedback/)
   
   返信が含まれるトピック: [ver 4.5.2にてoptions.phpのimage_default_alignなど（メディア初期設定）が効かない](https://ja.wordpress.org/support/topic/ver-452%e3%81%ab%e3%81%a6optionsphp%e3%81%aeimage_default_align%e3%81%aa%e3%81%a9%ef%bc%88%e3%83%a1%e3%83%87%e3%82%a3%e3%82%a2%e5%88%9d%e6%9c%9f%e8%a8%ad%e5%ae%9a%ef%bc%89%e3%81%8c%e5%8a%b9%e3%81%8b/)
 *  [luvjapan](https://ja.wordpress.org/support/users/luvjapan/)
 * (@luvjapan)
 * [10年、 4ヶ月前](https://ja.wordpress.org/support/topic/ver-452%e3%81%ab%e3%81%a6optionsphp%e3%81%aeimage_default_align%e3%81%aa%e3%81%a9%ef%bc%88%e3%83%a1%e3%83%87%e3%82%a3%e3%82%a2%e5%88%9d%e6%9c%9f%e8%a8%ad%e5%ae%9a%ef%bc%89%e3%81%8c%e5%8a%b9%e3%81%8b/#post-180487)
 * こんばんは。
 * こちらの情報はいかがでしょうか？
 * こちらはギャラリー表示の場合ですが参考になればと思います。
 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [content(本文)表示とexcerpt(抜粋)表示を切り替えて表示したいです。](https://ja.wordpress.org/support/topic/content%e6%9c%ac%e6%96%87%e8%a1%a8%e7%a4%ba%e3%81%a8excerpt%e6%8a%9c%e7%b2%8b%e8%a1%a8%e7%a4%ba%e3%82%92%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e3%81%a6%e8%a1%a8%e7%a4%ba%e3%81%97%e3%81%9f%e3%81%84/)
 *  トピック投稿者 [luvjapan](https://ja.wordpress.org/support/users/luvjapan/)
 * (@luvjapan)
 * [10年、 4ヶ月前](https://ja.wordpress.org/support/topic/content%e6%9c%ac%e6%96%87%e8%a1%a8%e7%a4%ba%e3%81%a8excerpt%e6%8a%9c%e7%b2%8b%e8%a1%a8%e7%a4%ba%e3%82%92%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e3%81%a6%e8%a1%a8%e7%a4%ba%e3%81%97%e3%81%9f%e3%81%84/#post-178320)
 * kimipooh様、本当にありがとうございます。
 * まさに自分が追い求めていた形です。
 * 自分の環境では functions.php の方に
 *     ```
       function new_the_excerpt( $excerpt ) {
            $excerpt_length = 200;
            $content = apply_filters('the_content', get_the_content());
            $content = strip_shortcodes(strip_tags(get_the_content(), '<i><p><br><span>'));
            $content = mb_substr ( $content, 0, $excerpt_length, 'UTF-8');
            return $content;
       }
       ```
   
 * でショートコードも消えました！
 * `$content = apply_filters('the_content', get_the_content());`
    の一行は試しに
   削除してみたところ表示は変わらないのですがこのタグはなくてはまずいでしょうか？
 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [content(本文)表示とexcerpt(抜粋)表示を切り替えて表示したいです。](https://ja.wordpress.org/support/topic/content%e6%9c%ac%e6%96%87%e8%a1%a8%e7%a4%ba%e3%81%a8excerpt%e6%8a%9c%e7%b2%8b%e8%a1%a8%e7%a4%ba%e3%82%92%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e3%81%a6%e8%a1%a8%e7%a4%ba%e3%81%97%e3%81%9f%e3%81%84/)
 *  トピック投稿者 [luvjapan](https://ja.wordpress.org/support/users/luvjapan/)
 * (@luvjapan)
 * [10年、 4ヶ月前](https://ja.wordpress.org/support/topic/content%e6%9c%ac%e6%96%87%e8%a1%a8%e7%a4%ba%e3%81%a8excerpt%e6%8a%9c%e7%b2%8b%e8%a1%a8%e7%a4%ba%e3%82%92%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e3%81%a6%e8%a1%a8%e7%a4%ba%e3%81%97%e3%81%9f%e3%81%84/#post-178318)
 * 度々すみません。
    上記ですとショートコードが表示されましたので追加しました。
 * <div class=”post-content”>
    <?php if(has_excerpt()) { the_excerpt(); echo ”; }
   else { if(mb_strlen($post->post_content, ‘UTF-8’)>200){ $content= mb_substr(strip_tags(
   $post->post_content, ‘<i><p><span>’), 0, 200, ‘UTF-8’); $content = strip_shortcodes(
   $content ); echo $content.”; } else { echo strip_shortcodes(strip_tags(get_the_content(),‘
   <i><p><span>’)); } } ?> </div>
 * この様にいたしました。
    間違いなどがございましたらアドバイスいただければ助かり
   ます。
 * 宜しくお願い致します。
 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [content(本文)表示とexcerpt(抜粋)表示を切り替えて表示したいです。](https://ja.wordpress.org/support/topic/content%e6%9c%ac%e6%96%87%e8%a1%a8%e7%a4%ba%e3%81%a8excerpt%e6%8a%9c%e7%b2%8b%e8%a1%a8%e7%a4%ba%e3%82%92%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e3%81%a6%e8%a1%a8%e7%a4%ba%e3%81%97%e3%81%9f%e3%81%84/)
 *  トピック投稿者 [luvjapan](https://ja.wordpress.org/support/users/luvjapan/)
 * (@luvjapan)
 * [10年、 4ヶ月前](https://ja.wordpress.org/support/topic/content%e6%9c%ac%e6%96%87%e8%a1%a8%e7%a4%ba%e3%81%a8excerpt%e6%8a%9c%e7%b2%8b%e8%a1%a8%e7%a4%ba%e3%82%92%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e3%81%a6%e8%a1%a8%e7%a4%ba%e3%81%97%e3%81%9f%e3%81%84/#post-178317)
 * .post-content a {
    display:none ; } はなくても平気でした。
 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [content(本文)表示とexcerpt(抜粋)表示を切り替えて表示したいです。](https://ja.wordpress.org/support/topic/content%e6%9c%ac%e6%96%87%e8%a1%a8%e7%a4%ba%e3%81%a8excerpt%e6%8a%9c%e7%b2%8b%e8%a1%a8%e7%a4%ba%e3%82%92%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e3%81%a6%e8%a1%a8%e7%a4%ba%e3%81%97%e3%81%9f%e3%81%84/)
 *  トピック投稿者 [luvjapan](https://ja.wordpress.org/support/users/luvjapan/)
 * (@luvjapan)
 * [10年、 4ヶ月前](https://ja.wordpress.org/support/topic/content%e6%9c%ac%e6%96%87%e8%a1%a8%e7%a4%ba%e3%81%a8excerpt%e6%8a%9c%e7%b2%8b%e8%a1%a8%e7%a4%ba%e3%82%92%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e3%81%a6%e8%a1%a8%e7%a4%ba%e3%81%97%e3%81%9f%e3%81%84/#post-178316)
 * kimipooh様、返事が遅くなり申し訳ありません。そして、回答ありがとうございます。
 * 色々試行錯誤したのですがなかなかうまくいかず
    かなり強引でスマートではない方法
   でとりあえずは思う様に表示させております。
 * <div class=”post-content”>
    <?php if(has_excerpt()) { the_excerpt(); echo ”; }
   else { if(mb_strlen($post->post_content, ‘UTF-8’)>200){ $content= mb_substr(strip_tags(
   $post->post_content, ‘<i><p><span>’), 0, 200, ‘UTF-8’); $content = strip_shortcodes(
   $content ); echo $content.”; } else { echo strip_tags(get_the_content(), ‘<i>
   <p><span>’); } } ?> </div>
 * loopにてこの様に記述し、画像が2つ表示されるところをcssで
    .post-content a { display:
   none ; }
 * と言う様にしました。
 * もっとスマートな方法がありそうです。
 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [content(本文)表示とexcerpt(抜粋)表示を切り替えて表示したいです。](https://ja.wordpress.org/support/topic/content%e6%9c%ac%e6%96%87%e8%a1%a8%e7%a4%ba%e3%81%a8excerpt%e6%8a%9c%e7%b2%8b%e8%a1%a8%e7%a4%ba%e3%82%92%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e3%81%a6%e8%a1%a8%e7%a4%ba%e3%81%97%e3%81%9f%e3%81%84/)
 *  トピック投稿者 [luvjapan](https://ja.wordpress.org/support/users/luvjapan/)
 * (@luvjapan)
 * [10年、 4ヶ月前](https://ja.wordpress.org/support/topic/content%e6%9c%ac%e6%96%87%e8%a1%a8%e7%a4%ba%e3%81%a8excerpt%e6%8a%9c%e7%b2%8b%e8%a1%a8%e7%a4%ba%e3%82%92%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e3%81%a6%e8%a1%a8%e7%a4%ba%e3%81%97%e3%81%9f%e3%81%84/#post-178256)
 * kimipooh様、回答ありがとうございます。
 * こちらの方は以前試していまして、再度挑戦してみたのですがcontentだけだと改行が
   うまく
 * 表示されるのですがexcerptのタグを使用すると改行がきかなくなるという状況です。
 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [content(本文)表示とexcerpt(抜粋)表示を切り替えて表示したいです。](https://ja.wordpress.org/support/topic/content%e6%9c%ac%e6%96%87%e8%a1%a8%e7%a4%ba%e3%81%a8excerpt%e6%8a%9c%e7%b2%8b%e8%a1%a8%e7%a4%ba%e3%82%92%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e3%81%a6%e8%a1%a8%e7%a4%ba%e3%81%97%e3%81%9f%e3%81%84/)
 *  トピック投稿者 [luvjapan](https://ja.wordpress.org/support/users/luvjapan/)
 * (@luvjapan)
 * [10年、 4ヶ月前](https://ja.wordpress.org/support/topic/content%e6%9c%ac%e6%96%87%e8%a1%a8%e7%a4%ba%e3%81%a8excerpt%e6%8a%9c%e7%b2%8b%e8%a1%a8%e7%a4%ba%e3%82%92%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e3%81%a6%e8%a1%a8%e7%a4%ba%e3%81%97%e3%81%9f%e3%81%84/#post-178205)
 * Okamoto様、回答ありがとうございます。
    難しいですが現在翻訳しながら勉強中です。
 * 何度もすみません。。。
 * <?php if ( has_excerpt() ) : $excerpt = get_the_excerpt(); ?>
    <div class=”excerpt”
   ><?php echo nl2br($excerpt); ?></div> <?php endif; ?> 上記の抜粋のみの表示と
 * 下記の改行形成されされ、ショートコードを削除したコンテンツ文章を抜粋を優先に切り替え
   表示出来ないでしょうか？
    <p><?php } ?> <?php //i,p,br,spanを残す if(mb_strlen(
   $post->post_content, ‘UTF-8’)>200){ $content= mb_substr(strip_tags($post->post_content,‘
   <i><p><span>’), 0, 200, ‘UTF-8’); $content = strip_shortcodes( $content ); echo
   $content.”; }else{ echo strip_tags(the_content(), ‘<i><p></p>
 * <span></span>’);
    } ?></p>
 * 抜粋がある場合は抜粋表示し、ない場合はコンテンツから指定文字数表示するというかん
   じです。
 * また、もう少し他に方法があればアドバイスをいただければと思います。
 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [content(本文)表示とexcerpt(抜粋)表示を切り替えて表示したいです。](https://ja.wordpress.org/support/topic/content%e6%9c%ac%e6%96%87%e8%a1%a8%e7%a4%ba%e3%81%a8excerpt%e6%8a%9c%e7%b2%8b%e8%a1%a8%e7%a4%ba%e3%82%92%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e3%81%a6%e8%a1%a8%e7%a4%ba%e3%81%97%e3%81%9f%e3%81%84/)
 *  トピック投稿者 [luvjapan](https://ja.wordpress.org/support/users/luvjapan/)
 * (@luvjapan)
 * [10年、 4ヶ月前](https://ja.wordpress.org/support/topic/content%e6%9c%ac%e6%96%87%e8%a1%a8%e7%a4%ba%e3%81%a8excerpt%e6%8a%9c%e7%b2%8b%e8%a1%a8%e7%a4%ba%e3%82%92%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e3%81%a6%e8%a1%a8%e7%a4%ba%e3%81%97%e3%81%9f%e3%81%84/#post-178190)
 * Hinaloe様
 * ご回答ありがとうございます。
    get_the_contentにて書き換えてみたり色々試してみ
   ました。
 * 抜粋表示はうまくいったのですが
 * やはり抜粋が入力がない場合でのcontent取得文章で改行がうまくできません。
 * フィルターの適用はどの様にしたらよろしいでしょうか？
 * excerptとcontentをあるかないかで切り替えて表示する様なことはできないのでしょう
   か？
 * 恐れ入りますが教えていただければ幸いです。
 * 宜しくお願い致します。
 *   フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   返信が含まれるトピック: [Blog一覧にて囲み式のショートコードを非表示にしたいです。](https://ja.wordpress.org/support/topic/blog%e4%b8%80%e8%a6%a7%e3%81%ab%e3%81%a6%e5%9b%b2%e3%81%bf%e5%bc%8f%e3%81%ae%e3%82%b7%e3%83%a7%e3%83%bc%e3%83%88%e3%82%b3%e3%83%bc%e3%83%89%e3%82%92%e9%9d%9e%e8%a1%a8%e7%a4%ba%e3%81%ab%e3%81%97/)
 *  トピック投稿者 [luvjapan](https://ja.wordpress.org/support/users/luvjapan/)
 * (@luvjapan)
 * [10年、 4ヶ月前](https://ja.wordpress.org/support/topic/blog%e4%b8%80%e8%a6%a7%e3%81%ab%e3%81%a6%e5%9b%b2%e3%81%bf%e5%bc%8f%e3%81%ae%e3%82%b7%e3%83%a7%e3%83%bc%e3%83%88%e3%82%b3%e3%83%bc%e3%83%89%e3%82%92%e9%9d%9e%e8%a1%a8%e7%a4%ba%e3%81%ab%e3%81%97/#post-178183)
 * nobitaさん、回答ありがとうございます。
    $content = strip_shortcodes( $content);
   を追記することによって解決致しました。 助かりました。ありがとうございます。

9件の返信を表示中 - 16 - 24件目 (全24件中)

[←](https://ja.wordpress.org/support/users/luvjapan/replies/?output_format=md) [1](https://ja.wordpress.org/support/users/luvjapan/replies/?output_format=md)
2