Title: Using query_posts function disables page view
Last modified: August 19, 2016

---

# Using query_posts function disables page view

 *  Resolved [stoarcecreierul](https://wordpress.org/support/users/stoarcecreierul/)
 * (@stoarcecreierul)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/using-query_posts-function-disables-page-view/)
 * I am using query_posts function to show posts from only one category on my home
   page. By doing this, the blog pages show only the first page. So if the adress
   is `http://www.my*site.com/page/3/` the page shows the exact same thing as in`
   http://www.my*site.com/`.
 * I use this function inserted in `index.php` right after the header:
 *     ```
       <?php get_header(); ?>
   
       <!-- Showing posts from category 3 alone: -->
       <?php
             query_posts("cat=3");
       ?>
   
           <div id="content">
   
               <div id="main">
   
       <!-- the rest of index.php -->
       ```
   
 * Is there a way to fix this? Or maybe another way to show posts from only one 
   category on the main page and having subpages working?

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/using-query_posts-function-disables-page-view/#post-1441787)
 * Example of proper pagination:
 *     ```
       <?php
       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
       query_posts('cat=3&posts_per_page='.get_option('posts_per_page').'&paged=' . $paged);
       ?>
       ```
   
 * See WordPress Default theme’s wp-content/themes/default/index.php for example
   of using the [template tags](http://codex.wordpress.org/Template_Tags), [previous_posts_link()](http://codex.wordpress.org/Template_Tags/previous_posts_link)
   and [next_posts_link()](http://codex.wordpress.org/Template_Tags/next_posts_link).
 *  Thread Starter [stoarcecreierul](https://wordpress.org/support/users/stoarcecreierul/)
 * (@stoarcecreierul)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/using-query_posts-function-disables-page-view/#post-1441798)
 * Right on. Thank you sir!

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

The topic ‘Using query_posts function disables page view’ is closed to new replies.

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)
 * [disables](https://wordpress.org/support/topic-tag/disables/)
 * [function](https://wordpress.org/support/topic-tag/function/)
 * [only](https://wordpress.org/support/topic-tag/only/)
 * [page](https://wordpress.org/support/topic-tag/page/)
 * [post](https://wordpress.org/support/topic-tag/post/)
 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)
 * [show](https://wordpress.org/support/topic-tag/show/)
 * [view](https://wordpress.org/support/topic-tag/view/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [stoarcecreierul](https://wordpress.org/support/users/stoarcecreierul/)
 * Last activity: [16 years, 1 month ago](https://wordpress.org/support/topic/using-query_posts-function-disables-page-view/#post-1441798)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
