0

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(); ?>

1 Answer 1

0

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);
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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