• HOME
  • WordPress
  • get_postの時にたまにthe_contentが表示されない場合

get_postの時にたまにthe_contentが表示されない場合

<?php $this_content= wpautop($post->post_content); echo $this_content; ?>

配列からデータを取得しそこにwpautopの関数をかけて表示させる方法。
基本上記がおすすめ。
下記の方法もあるがカスタムフィールドテンプレートなどを使いmetaを出力していると下記の方法だと
metaが出力されない状態になる。

<?php
$myposts = get_posts('numberposts=3&orderby=post_date');
foreach($myposts as $mypost) :
        the_post();//これをくわえる
?>