• Resolved philgarrett

    (@philgarrett)


    So I am currently using the following code in my sidebar.php file:

    <?php if (is_category(8) || in_category(8)) { ?>
        <div id="subnav">
    	<?php	$catposts=get_posts('cat=8', 'numberposts =0');
    		if ($catposts) {
    		  foreach($catposts as $post) {
    			setup_postdata($post); ?>
    			<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    		  <?php  }
    		}
    	?>
        </div>
        <?php } ?>

    It’s supposed to pull the titles of all the posts in that category and list them as links. The problem is that it is limiting it to only the 5 most recent. If anyone has any idea why that might be it would be greatly appreciated.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Try

    get_posts('cat=8&showposts=-1');

    Thread Starter philgarrett

    (@philgarrett)

    Thank you very much, that worked perfectly. I realized after looking at your solution that I mis-read the codex and the use of “0” vs “-1”.

    Does combining the two arguments into one make a difference as well? or is it just for shortening and/or cleaning up the code a little bit?

    Thanks again, it was greatly appreciated to get a response so quickly.

    Actually I’m not sure the two arguments works. You can use a string of arguments as I presented or an array such as

    $args=array(
      'cat' => 8,
      'showposts' => -1
    );
    $catposts=get_posts($args);

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘This is limiting me to 5 posts, and I don’t know why’ is closed to new replies.