HighLab

wordpress文字制限

  • 公開日:
  • 更新日:
  • 文字数:436文字
$content= $post->post_content;
$content= str_replace("<!-- wp:paragraph -->","",$content);
$content= str_replace("<!-- /wp:paragraph -->","",$content);
$content= str_replace("<br>","",$content);
$content= str_replace("<p>","",$content);
$content= str_replace("</p>","",$content);
$content= strip_tags($content);

if(mb_strlen($content, 'UTF-8')>50){
  $content= mb_substr($content, 0, 50, 'UTF-8');
}