1. HOME
  2. ホームページ作成の小技
  3. 【wordpress】get_the_content()で文字だけ取得したい・ショートコード(ビジュアルコンポーザー)をカットして…

TECHNIQUES

ホームページ作成の小技

wordpress

【wordpress】get_the_content()で文字だけ取得したい・ショートコード(ビジュアルコンポーザー)をカットして本文のみ表示させたい

記事一覧を表示するときに、get_the_content + strip_tags で、タグはカットしたのだが、

ビジュアルコンポーザーのショートコードがガッツリ表示されているぅぅぅぅ。

という時は、一旦 do_shortcode で取得してから、 strip_tags  で、文字のみとれます!

↓ こんな感じです

$post_content = do_shortcode(get_the_content()); 
$post_content = strip_tags($post_content);