1

I'm trying to edit the default post-page of WordPress so that it displays all posts as opposed to the most recent 10, but I'm unsure which file to edit.

I tried to edit wp_get_recent_posts function in wp-includes/post.php, but it had no effect. Can someone point me in the right direction?

function wp_get_recent_posts( $args = array(), $output = ARRAY_A ) {

if ( is_numeric( $args ) ) {
    _deprecated_argument( __FUNCTION__, '3.1', __( 'Passing an integer number of posts is deprecated. Pass an array of arguments instead.' ) );
    $args = array( 'numberposts' => absint( $args ) );
}

// Set default arguments.
$defaults = array(
    'numberposts' => 1000, 'offset' => 0,
    'category' => 0, 'orderby' => 'post_date',
    'order' => 'DESC', 'include' => '',
    'exclude' => '', 'meta_key' => '',
    'meta_value' =>'', 'post_type' => 'post', 'post_status' => 'draft, publish, future, pending, private',
    'suppress_filters' => true
);
0

you have to set "post_per_page" to "-1". Add this code to your home or index.php.

WP_Query (recommended)

$args = array('posts_per_page' => -1);
$the_query = new WP_Query( $args );

if ( $the_query->have_posts() ) {
  while ( $the_query->have_posts() ) : $the_query->the_post();
    the_title();
    the_content();
  endwhile;

  /* Restore original Post Data */
  wp_reset_postdata();

} else {
  // no posts found
}

query_posts() way

// Args that you pass to loop
$args = array('posts_per_page' => -1);

// The Query
query_posts( $args );

// The Loop
while ( have_posts() ) : the_post();
    the_title();
    the_content();
endwhile;

// Reset Query
wp_reset_query();

Alternatively you can go to Dashboard -> Settings -> Reading and set maximum posts per page to "1000" or something.

2
  • query_posts is not recommended. Please use WP_Query. Check this for more info
    – bravokeyl
    Sep 19 '16 at 13:17
  • @bravokeyl well you're right, I just wanted to give him quick solution (post_per_page). Just added WP_Query code to the answer, cheers. Sep 19 '16 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.