[英]the_content(); doesn't print anything in my wordpress custom template page
我必须在我的wordpress博客的自定义模板页面中显示2篇文章,但此代码没有显示任何内容。
$myposts = get_posts("numberposts=2&category=3");
foreach($myposts as $post) : the_content(); endforeach;
但如果我尝试print_r($myposts);
我可以说有一个数组..我可以解决这个问题吗? 非常感谢
写这一行:
the_post();
在使用之前:
the_content();
雅需要使用循环 !
query_posts("numberposts=2&category=3");
while ( have_posts() ): the_post();
the_content();
endwhile;
你可以尝试这个: -
<ul>
<?php
global $post;
$myposts = get_posts('numberposts=5&offset=1&category=1');
foreach($myposts as $post) :
setup_postdata($post);
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php the_content() ?>
<?php endforeach; ?>
</ul>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.