【发布时间】:2012-07-21 03:16:19
【问题描述】:
我正在尝试创建一个循环,从任何帖子加载随机图像,同时检索特定页面的摘录。我已经完成了随机发布部分,但无法获取它来检索页面摘录......我想我可能需要在它们自己的循环中查询页面,但我不知道该怎么做。我已经安装了获取页面摘录支持等功能,但我认为我在循环中做错了,任何帮助将不胜感激。
<div class="postimage">
<?php if (have_posts()) :
query_posts('showposts=1&orderby=rand');
while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('blog-post-image'); ?></a>
<div class="borderimage"></div>
<div class="tagline"><h1><?php the_excerpt('$page_id=8'); ?> </h1>
</div>
</div>
</div>
<?php endwhile; else : endif; ?>
【问题讨论】:
-
试试
the_excerpt()(不带参数)。另外,你应该把query_posts语句放在if (have_posts())之前 -
我需要参数,因为我试图从特定页面获取摘录,同时还从随机帖子中绘制图像。
-
啊。知道了。请参阅下面的答案。