Why get_posts are only showing five posts (retrieved by assigning a category to them?

If you look at the get_posts documentation on Codex, you can see there’s a parameter for number of posts you want to display:

$numberposts
(integer) (optional) Number of posts to return. Set to 0 to use the max number of posts per page. Set to
-1 to remove the limit.

Default: 5

That’s why it’s displaying just 5 posts. You need to add the parameter to your args array:

$args = array(
    'category_name' => 'Voice Page (Right Column)', 
    'orderby' => 'DESC', 
    'posts_per_page'=>-1, 
    'numberposts'=>-1
);

Leave a Comment