Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using this in a file named category-portfolio.php which is for the archives page of my portfolio. I don't want to use cat= to specify a specific category. But when I don't use cat= it pulls up every post regardless of category. How do I make this code pull up only the current/relevant/portfolio category? Thanks a million!

<?php get_header(); ?>

<div id="container">
<div id="portfolio_content">

<!-- Grab posts -->
<?php
query_posts('posts_per_page=9&paged='.$paged); 
if (have_posts()) :
?>

<div id="portfolio_wrap">
<?php while (have_posts()) : the_post(); ?>  

<!-- Get the image -->
<div class="img">
<a href="<?php the_permalink() ?>">


<?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'thmb-portfolio' ); } ?>

<!-- Excerpt title -->
<span class="title"><?php the_title(); ?></span></a>

<!-- Excerpt description -->
<div class="desc"><?php my_excerpt('short'); ?></div>

</div>

<?php endwhile; ?>

<!-- Next/Previous Posts -->
<?php if (function_exists("pagination")) {
    pagination($additional_loop->max_num_pages);
} ?>

</div>

<!-- #portfolio_wrap -->
<?php endif; ?>

</div>
<?php get_sidebar(); ?>
</div>
</div>
<?php get_footer(); ?>
share|improve this question

1 Answer 1

up vote 0 down vote accepted

The problem is that your call to query_posts is overwriting the original query for the page. You have to get the original query, then modify any params from there.

global $query_string;
// start with the original query
$myquery = wp_parse_args($query_string);
// make any changes to the query here
$myquery['posts_per_page'] = 9;
query_posts($myquery);
share|improve this answer
    
Thank you, big help! –  Lucas Jul 14 '11 at 21:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.