category query not working in loop
-
Hi all,
I set up a pretty customized loop which I’m hoping to maintain, but for some reason can’t figure out how to get it to display posts from just one category and it’s driving me mad. i’ve tried several calls but none seem to work, to display category 1 and not 4.
the code i’m using is here: any help appreciated!
<?php $query = new WP_Query( ‘cat=1’ ); ?>
<?php if (have_posts(‘category=1’)) : ?>
<?php $post = $posts[0]; $c=0;?>
<?php while (have_posts()) : the_post(); ?><?php $c++;
if( !$paged && $c == 1) :?>
<li class=”firstpost”>
“><?php the_post_thumbnail(); ?>
<h2><?php if (strlen($post->post_title) > 110) {
echo substr(the_title($before = ”, $after = ”, FALSE), 0, 110) . ‘…’; } else {
the_title();
} ?></h2>
<?php the_excerpt(); ?><?php else :?>
<li class=”post”>
“><?php the_post_thumbnail(); ?>
<h2><?php if (strlen($post->post_title) > 45) {
echo substr(the_title($before = ”, $after = ”, FALSE), 0, 65) . ‘…’; } else {
the_title();
} ?></h2><span class=”postfooter”><?php the_time(‘M j, Y’) ?></span>
<?php endif;?>
<?php endwhile; ?>
<div class=”navigation”>
<div class=”alignleft”><?php next_posts_link(‘« Older Entries’) ?></div>
<div class=”alignright”><?php previous_posts_link(‘Newer Entries »’) ?></div>
</div><?php endif; ?>
the page can be found at http://www.ribbonmusic.com/news/
thank you!!!
The topic ‘category query not working in loop’ is closed to new replies.