I have the following code inside my single.php page:
UPDATED CODE
<?php if (have_posts()) : the_post();
$post_id = get_the_ID();
if ( is_single() ) {
$cats = get_the_category();
$cat = $cats[0];
} else {
// category archives
$cat = get_category( get_query_var( 'cat' ) );
}
$cat_id = $cat->cat_ID;
$cat_name = $cat->name;
$cat_slug = $cat->slug;
?>
<?php query_posts('cat='.$cat_id); ?>
<?php if (have_posts()) : ?>
<div id="sidebar">
<h3><?php echo get_cat_name($cat_id); $theCount = 0; ?></h3>
<ul class="info-list">
<?php while (have_posts()) : the_post(); $theCount += 1; echo 'debug>' . $theCount; ?>
<li <?php if ($post_id == get_the_ID()) {echo 'class="active"';} ?>>
<a href="<?php the_permalink(); ?>">
<span><?php the_title(); ?></span>
</a>
</li>
<?php endwhile; ?>
</ul>
</div>
<?php endif; ?>
<?php endif; ?>
Problem being is that it only seems to grab the last 10 posts in that category where i know i have 16 posts for that sidebar to display.
Where in the code could i find where its limiting the return values??
UPDATE
<?php if (have_posts()) : the_post();
$post_id = get_the_ID();
if ( is_single() ) {
$cats = get_the_category();
$cat = $cats[0];
} else {
// category archives
$cat = get_category( get_query_var( 'cat' ) );
}
$cat_id = $cat->cat_ID;
$cat_name = $cat->name;
$cat_slug = $cat->slug;
$cat_query_args = array(
// Include posts from category with ID $cat_id
'cat' => $cat_id,
// Include all posts
'posts_per_page' => -1
);
$cat_query = new WP_Query( $cat_query_args );
if ( $cat_query->have_posts() )
?>
<div id="sidebar">
<h3><?php echo get_cat_name($cat_id); $theCount = 0; ?></h3>
<ul class="info-list">
<?php
while $cat_query->have_posts() : $cat_query->the_post();
$theCount += 1; echo 'debug>' . $theCount;
?>
<li <?php if ($post_id == get_the_ID()) {echo 'class="active"';} ?>>
<a href="<?php the_permalink(); ?>">
<span><?php the_title(); ?></span>
</a>
</li>
<?php
endwhile;
?>
</ul>
</div>
<?php
endif;
?>
<?php endif; ?>
<?php wp_reset_query(); ?>