内容(); 不会在我的wordpress自定义模板页面中打印任何内容

Luk*_*uke 3 php wordpress

我必须在我的wordpress博客的自定义模板页面中显示2篇文章,但此代码没有显示任何内容.

  $myposts = get_posts("numberposts=2&category=3"); 
foreach($myposts as $post) : the_content(); endforeach;
Run Code Online (Sandbox Code Playgroud)

但如果我试着,print_r($myposts);我可以说有一个数组..我可以解决这个问题吗?非常感谢

小智 6

写这一行:

the_post();
Run Code Online (Sandbox Code Playgroud)

在使用之前:

the_content();
Run Code Online (Sandbox Code Playgroud)