Title: query_posts
Last modified: August 19, 2016

---

# query_posts

 *  Resolved [Roy](https://wordpress.org/support/users/gangleri/)
 * (@gangleri)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/query_posts-3/)
 * Sorry for the silly question, but can I combine
 *     ```
       <?php query_posts( 'post_type=blog');
        if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
       ```
   
 * with
    `query_posts('posts_per_page=5');` and if yes, how?
 * My trial-and-error method failed.
 * The idea is to have a different number of posts per page than the setting under“
   reading”.

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

 *  [DigitalSquid](https://wordpress.org/support/users/twelvefootsnowman/)
 * (@twelvefootsnowman)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/query_posts-3/#post-1611372)
 *     ```
       $loop = new WP_Query( array( 'post_type' => 'blog', 'posts_per_page' => 5 ) );
       while ( $loop->have_posts() ) : $loop->the_post();
       ```
   
 *  Thread Starter [Roy](https://wordpress.org/support/users/gangleri/)
 * (@gangleri)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/query_posts-3/#post-1611375)
 * Thanks, but sorry again, that does not seem to be:
 *     ```
       <?php $loop = new WP_Query( array( 'post_type' => 'blog', 'posts_per_page' => 5 ) );
       while ( $loop->have_posts() ) : $loop->the_post(); ?>
       ```
   
 * This results in a blank screen (I simply replaced the block I opened with, maybe
   you didn’t mean that?
 *  [DigitalSquid](https://wordpress.org/support/users/twelvefootsnowman/)
 * (@twelvefootsnowman)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/query_posts-3/#post-1611389)
 * Strange, it worked on my blog.
 * Try this instead then:
 *     ```
       <?php
       $args = array(
       	'posts_per_page' => 5,
       	'post_type' => 'blog'
       );
       query_posts($args);
       if ( have_posts() ) : while ( have_posts() ) : the_post();
       ?>
       ```
   
 * Here’s the Codex page with the info: [http://codex.wordpress.org/Function_Reference/query_posts](http://codex.wordpress.org/Function_Reference/query_posts)
 *  Thread Starter [Roy](https://wordpress.org/support/users/gangleri/)
 * (@gangleri)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/query_posts-3/#post-1611392)
 * Jiha! The result is not pretty, but it (temporarily) patches a problem.
    Thanks
   a lot.

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

The topic ‘query_posts’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [Roy](https://wordpress.org/support/users/gangleri/)
 * Last activity: [15 years, 10 months ago](https://wordpress.org/support/topic/query_posts-3/#post-1611392)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
