WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 -->
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>


<?php endwhile; ?>

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


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

<?php get_sidebar(); ?>
<?php get_footer(); ?>
share|improve this question
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;
share|improve this answer
Thank you, big help! – Lucas Jul 14 '11 at 21:54

Your Answer


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.