Title: Load more posts on button click
Last modified: August 24, 2016

---

# Load more posts on button click

 *  [omka_b](https://wordpress.org/support/users/omka_b/)
 * (@omka_b)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/load-more-posts-on-button-click/)
 * Hi,
 * I want to load more posts on button click but it only load 2 posts and no more.
   Please help.
 * <?php
 *  if (isset($_POST[‘button’])) :
    $ids=array(); query_posts(array(‘posts_per_page
   =2’),array(‘posts__not_in=$ids’));
 *  //query_posts(array(‘post__not_in’ => $ids));
    while ( have_posts() ): the_post();
 *  /*
    * Include the Post-Format-specific template for the content. * If you want
   to override this in a child theme, then include a file * called content-___.php(
   where ___ is the Post Format name) and that will be used instead.*/
 *  $ids[] = get_the_ID();
    get_template_part( ‘content’); // End the loop. endwhile;
   wp_reset_query(); endif; ?>
 *  <?php endif; ?>

Viewing 1 replies (of 1 total)

 *  [accuwebhosting](https://wordpress.org/support/users/accuwebhosting/)
 * (@accuwebhosting)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/load-more-posts-on-button-click/#post-6164276)
 * Hi,
 * load more posts button loads only 2 posts because you have passed following argument:
 * (array(‘posts_per_page=2’)
 * You’ll have to replace 2 with the number of posts you want to display. In other
   case, you do not pass this argument, button will show all posts.
 * Thanks,

Viewing 1 replies (of 1 total)

The topic ‘Load more posts on button click’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [accuwebhosting](https://wordpress.org/support/users/accuwebhosting/)
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/load-more-posts-on-button-click/#post-6164276)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
