Reputation: 21
today i need to get all the posts from a specific category on wordpress.
The code it's pretty basic, and it's like that:
print_r(get_posts(array('numberposts' => -1, 'category' => 3)));
The id of the category it's obviously 3. But i receive always the last 5 posts of that category, not all the post present there (something like 60posts).
Anyone know why could happen this strange stuff?
Upvotes: 1
Views: 49
Reputation: 655
Try something like this:
<ul>
<?php
$args = array( 'numberposts' => -1,'category' => 3 );
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endforeach; wp_reset_postdata();?>
</ul>
If this works for you, all you need to do then is to change the output display(the ul and li)
Upvotes: 1