# get_the_excerpt() ,get_the_content()を使う

- リンク: https://torounit.com/blog/get_the_excerpt-get_the_content%e3%82%92%e4%bd%bf%e3%81%86/
- 公開日: 2010-08-11T16:23:16+09:00
- 作成者: Toro\_Unit

WordPressで新聞のようなサイトを作っていたときに記事の抜粋を複数カテゴリで表示した
かったのですが、カテゴリごとに抜粋の長さを変えようとしたときのメモ。

the_excerpt()は直接echoしてしまうので、何か無いかなとwp-includes/post-template.php
を探っていたらget_the_excerpt() ,get_the_content()なんてものを発見。

この関数はreturnで変数返すだけなので、

[php]<?php echo(mb_strimwidth(get_the_excerpt(), 0, 50, "…"));?>[/php]

ていう感じで使ってあげれば文字数をその場その場で設定しつつ、抜粋を表示することが
できます。
