Thanks for this Kalessin. It worked great.
If i wanted to put this on a normal page. How would i do this? because it seems to just show the above code and ignore everything else.
I have the following:-
<?php
/*
Template Name: Sign Up
*/
?>
<?php get_header(); ?>
<?php get_sidebar(); ?>
<div id="content" class="contact">
<div id="randreviews">
<?php query_posts('cat=6&showposts=5'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php
$images = get_children(
array(
'post_parent' => $post->ID,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'orderby' => 'menu_order'
)
);
if ( $images ) {
$count = 1;
foreach ( $images as $id => $image ) {
if( $count === 1 ) {
$img = wp_get_attachment_url( $image->ID );
$link = get_permalink( $post->ID );
print "\n\n" . '<a href="' . $link . '"><img src="' . $img . '" alt="" /></a>';
}
$count++;
}
}
?>
<?php endwhile; ?>
<?php endif; ?>
</div>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php endwhile; ?>
<?php else : ?>
<h2>Not found!</h2>
<p><?php _e('Sorry, this page does not exist.'); ?></p>
<?php endif; ?>
<?php if(is_page(array('80'))) {
insert_cform('2');
} ?>
</div>
<?php get_footer(); ?>