I am trying to create a loop that loads a random image from any posts, whilst also retrieving the excerpt of a specific page. I have done the random post part, but cannot get it to retrieve the page excerpt… I think I may need to query the pages in their own loop but I’m not sure how to do this. I have installed the function to get page excerpt support etc. but I think I am doing something wrong within the loop, any help would be appreciated.
<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; ?>
query_posts
replaces the global$wp_query
, which you don’t want to do since you want to keep that query for your page. Try this instead…