• Just wondering if anyone could tell me how to make the following code display posts of only the current catergory. At the moment it displays post from all catergories.

    <?php $recent = new WP_Query("cat=$current_category&showposts=2"); while($recent->have_posts()) : $recent->the_post();?>
    <?php if( get_post_meta($post->ID, "hpbottom", true) ): ?>
    " rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;" src="<?php echo get_post_meta($post->ID, "hpbottom", true); ?>" alt="<?php the_title(); ?>" />
    <?php else: ?>
    " rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;" src="<?php bloginfo('template_url'); ?>/images/thumbnail.png" alt="<?php the_title(); ?>" />
    <?php endif; ?>
    <b>" rel="bookmark"><?php the_title(); ?></b>
    <?php the_content_limit(350, "[Read more of this review]"); ?>
    
    <div style="border-bottom:1px dotted #2255AA; margin-bottom:10px; padding:0px 0px 10px 0px; clear:both;"></div>
    
    <?php endwhile; ?>
Viewing 1 replies (of 1 total)
  • Assuming you have a value in $current_category try

    <?php $recent = new WP_Query('cat=' . $current_category . '&showposts=2');

Viewing 1 replies (of 1 total)

The topic ‘Display post by category’ is closed to new replies.