• 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 to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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.

    Also please remove
    $args = array($args);
    its not needed

    is that the code of index.php or of a custom page template?

    Thread Starter FalsAlarm

    (@falsalarm)

    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.