Here is the code I am using for my post.
<?php $recent = new WP_Query("cat=1&showposts=4"); while($recent->have_posts()) : $recent->the_post();?>
<div class="post">
<h2 class="postTitle"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<div class="postMeta">
<span class="date"><?php the_time('M.d, Y') ?></span> in
<span class="filed"><?php the_category(', '); ?></span>
<span class="commentcount"><?php comments_popup_link('Leave a Comment', '1 Comment', '% Comments'); ?></span>
</div>
<div class="postContent"><?php the_content(); ?></div>
</div> <!-- Closes Post -->
<?php endwhile; ?>
but if I try to add
<?php else; ?>
it throws an error. Where am I going wrong
Thanks
Not exactly sure what you mean, but I think you want to format it more like a traditional WordPress loop:
<?php $recent = new WP_Query("cat=1&showposts=4");
if ($recent->have_posts()) :
while($recent->have_posts()) : $recent->the_post();?>
<div class="post">
<h2 class="postTitle"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<div class="postMeta">
<span class="date"><?php the_time('M.d, Y') ?></span> in
<span class="filed"><?php the_category(', '); ?></span>
<span class="commentcount"><?php comments_popup_link('Leave a Comment', '1 Comment', '% Comments'); ?></span>
</div>
<div class="postContent"><?php the_content(); ?></div>
</div> <!-- Closes Post -->
<?php endwhile;
else :
//put your else code here
endif; ?>
peace~
Thanks, I did that first and added the wp-query for the category before the loop and all worked fine. I have another theme that uses this variable type and was trying to include it.
Thanks
JIM