Title: get_posts() not returning all posts
Last modified: April 20, 2018

---

# get_posts() not returning all posts

 *  [FalsAlarm](https://wordpress.org/support/users/falsalarm/)
 * (@falsalarm)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/get_posts-not-returning-all-posts/)
 * Hello everyone.
 * I’ve setup a bikini girls pictures blog at bikinigirlsgalore.com and I’ve got
   6 posts that are all published status.
 * For some odd reason, the get_posts() function doesn’t return all pages. As you
   can see by visiting the homepage there is only 5 posts still.
 * Can anyone help me figure out what is causing the problem why 5 posts show up
   and not 6.
 * below is my code.
 *     ```
       <?php
       $args = array(
       	'posts_per_page'   => -1,
       	'offset'           => 0,
       	'category'         => '',
       	'category_name'    => '',
       	'orderby'          => 'date',
       	'order'            => 'ASC',
       	'include'          => '',
       	'exclude'          => '',
       	'meta_key'         => '',
       	'meta_value'       => '',
       	'post_type'        => 'post',
       	'post_mime_type'   => '',
       	'post_parent'      => '',
       	'author'	   => '',
       	'author_name'	   => '',
       	'post_status'      => 'publish',
       	'suppress_filters' => true
       	//'numberposts'		=> -1
       );
   
       $args = array($args);
       	$posts_array = get_posts($args);
       	echo '<div class="row">';
       	//echo "<p>Found, " . count($posts_array) . "</p>";
       	foreach($posts_array as $post)
       	{
       		echo '<div class="col-sm-3 border" style="text-align:center;">';
       		echo "<h3 class='headers'><a href='" . $post->post_name ."'>" . $post->post_title . "</h3>";
       		echo "<p>" . $post->post_content . "</p></a>";
       		echo "</div>";
       	}
       echo '</div>';
   
       ?>
       ```
   
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fget_posts-not-returning-all-posts%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [hyperionstudios](https://wordpress.org/support/users/hyperionstudios/)
 * (@hyperionstudios)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/get_posts-not-returning-all-posts/#post-10200896)
 * can you try with
 *     ```
       $args = array(
       	'posts_per_page'   => -1,
       	'orderby'          => 'date',
       	'order'            => 'ASC',
       );
       ```
   
 * The rest of the options are already loading their default values.
 *  [hyperionstudios](https://wordpress.org/support/users/hyperionstudios/)
 * (@hyperionstudios)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/get_posts-not-returning-all-posts/#post-10200897)
 * Also please remove
    `$args = array($args);` its not needed
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/get_posts-not-returning-all-posts/#post-10200901)
 * is that the code of index.php or of a custom page template?
 *  Thread Starter [FalsAlarm](https://wordpress.org/support/users/falsalarm/)
 * (@falsalarm)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/get_posts-not-returning-all-posts/#post-10201144)
 * the code is in my index.php
 * Also, removing the $args = line resolved the issue and using the defaults must
   have helped because it is working now.
 * thank you everyone for the help, much appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘get_posts() not returning all posts’ is closed to new replies.

## Tags

 * [get_posts](https://wordpress.org/support/topic-tag/get_posts/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [FalsAlarm](https://wordpress.org/support/users/falsalarm/)
 * Last activity: [8 years, 1 month ago](https://wordpress.org/support/topic/get_posts-not-returning-all-posts/#post-10201144)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
