【发布时间】:2014-10-01 12:25:30
【问题描述】:
我的 Wordpress 网站有问题:
在我的博客循环中,只有第一篇文章显示了内容;其余的 the_content(); 似乎从未被调用(用“检查元素”检查)。
我的代码有问题吗?
php/html:
<section id="blogPosts" class="clearfix">
<?php $myposts = get_posts('');
foreach($myposts as $post) :
setup_postdata($post);
?>
<div id="post-<?php the_ID(); ?>" class="post clearfix">
<div class="postHeader clearfix">
<a href="<?php the_permalink();?>">
<h2><?php the_title(); ?></h2>
</a>
<h4><?php the_date(); ?></h4>
</div>
<div class="postTags clearfix">
<ul class="tagContainer clearfix">
<?php the_tags( '<li><div class="tagInline">',
'</div></li><li><div class="tagInline">',
'</div></li>'); ?>
</ul>
</div>
<div class="blogContent">
<?php the_content();?>
</div>
<div class="editPost">
<?php edit_post_link('<h4>Redigera detta inlägg', '', '</h4>'); ?>
</div>
<?php wp_link_pages(array('before' => 'Pages: ', 'next_or_number' => 'number')); ?>
<?php //comments_template(); ?>
</div>
<?php endforeach; wp_reset_postdata(); ?>
</section>
【问题讨论】:
-
get_posts('')看起来很可疑。不应该是一个参数数组吗? -
知道该数组应该是什么吗?