yuheijotaki.com

WordPress the_content(); のタグ除去+先頭◯文字

$content = $post->post_content;
$content = strip_tags($content);
$content = str_replace(array("\r\n","\r","\n"), ' ', $content);
$mb_content = mb_strlen($content,"UTF-8");
if ($mb_content > 65) {
	$content = mb_substr($content, 0, 65) . '…';
} else {
	$content =  $content;
}
echo $content;