3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

the_contentを文字数指定して 改行を反映させながら表示 (get_trim_str を使って...有無)

Last updated at Posted at 2013-12-21

<?php
$my_content = get_the_content(); //コンテンツ取得
$my_content = preg_replace("|(<img[^>]+>)|si","",$my_content); //イメージ要素をのぞく
$my_content = wpautop($my_content); //br p を調整
$my_content = strip_tags($my_content); //タグをのぞく

?>
<?php echo nl2br(get_trim_str(array('str'=>$my_content, 'len'=>100,'echo' => false))); ?>
//改行されてるところにbrを挿入する さらに独自関数 get_trim_strを使う echoをファルスにする。
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?