What is wrong with my loop or Query Object?
-
On my Index.php I want several loops. Each post displayed with title and a custom field related image. Each loop with five posts (title and image) in their own column. Here is the code:
<div id="cola"> <h3>News A:</h3> <?php $cool = new WP_Query('cat=5'); $cool->query('showposts=5'); while ($cool->have_posts()) : $cool->the_post(); $post_image = get_post_meta($post->ID, 'image', $single = true); $post_alt = get_post_meta($post->ID, 'alt', $single = true); ?> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent url to <?php the_title(); ?>"><?php the_title(); ?></a></h2><br /> <?php if($post_image !== '') { ?> <a href="<?php the_permalink(); ?>" title="<?php if($post_alt !== '') echo $post_alt; else the_title(); ?>"><img src="<?php echo $post_image; ?>" alt="<?php if($post_alt !== '') echo $post_alt; else the_title(); ?>" style="width:250px;height:190px; " /></a> <?php } else { echo 'missing image'; } ?> <?php endwhile; ?> </div>
But my index.php is just blank. Not the header. Not anything. And each QP Query object is uniqe and have posts. What is wrong?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘What is wrong with my loop or Query Object?’ is closed to new replies.