WordPress.org

Ready to get started?Download WordPress

Forums

Global post array not showing the right amount? (3 posts)

  1. bencharity
    Member
    Posted 3 years ago #

    I am using a global post array to return a list of posts from a certain category as outlined here: http://codex.wordpress.org/Template_Tags/get_posts

    But no matter what number I include with 'posts_per_page' => 10' within the array, it only shows five. It is obviously seeing what I put it because it responds to sort commands and the category selection. Am I missing something?

    My query:

    <?php
    global $post;
    $args = array('category' => 40, 'posts_per_page' => 10);
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) :	setup_postdata($post);
    ?>

    See it here: http://benjamincharity.com/code-snippets/

  2. Sergey Biryukov
    Trac Moderator
    Posted 3 years ago #

    Try numberposts parameter.

  3. bencharity
    Member
    Posted 3 years ago #

    Ahhh that worked!! Thank you so much Sergey!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags