Title: Fixing a problem with query_posts
Last modified: August 19, 2016

---

# Fixing a problem with query_posts

 *  [altoidboy](https://wordpress.org/support/users/altoidboy/)
 * (@altoidboy)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/fixing-a-problem-with-query_posts/)
 * I’m using the popular free template JournalCrunch, which is working wonderfully
   in all aspects except one: it appears to use query_posts in an unorthodox/incorrect
   way, so that my home page always displays the x most recent posts but does not
   properly allow for pagination.
 * After googling for help, I found this article which seems to spell out exactly
   why it’s not working ([http://scribu.net/wordpress/wp-pagenavi/right-way-to-use-query_posts.html](http://scribu.net/wordpress/wp-pagenavi/right-way-to-use-query_posts.html));
   however I lack the PHP experience to know how to mod this template to work correctly.
   Below, I’ve included the relevant code from my template; can anyone suggest the
   best way to replace it with a rewritten version that allows me to use pagination
   properly? (Note that I really don’t know PHP, so I can’t figure out what the 
   code below is doing, so that’s why I don’t know how to mod it.)
 *     ```
       <?php $postindex = 1;
       		 	if(!query_posts('showposts='.get_option('journal_home_posts').'&tag=homepost')){
       				if(get_option('journal_home_posts')!=''){
       			 		query_posts('showposts='.get_option('journal_home_posts'));
       				}else{
       					query_posts('showposts=6');
       				}
       			}else{
       				query_posts('showposts='.get_option('journal_home_posts').'&tag=homepost');
       				if(get_option('journal_home_posts')!=''){
       			 		query_posts('showposts='.get_option('journal_home_posts').'&tag=homepost');
       				}else{
       					query_posts('showposts=6&tag=homepost');
       				}
       			}
   
       		 if (have_posts()) : while (have_posts()) : the_post(); ?>
       			<div class="postBox <?php if(($postindex % 3) == 0){ echo 'lastBox';}?>">
       				<div class="postBoxInner">
       ```
   
 * (below this point, it begins drawing the custom post boxes using the class postBoxInner.)

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

 *  [bryanwiz](https://wordpress.org/support/users/bryanwiz/)
 * (@bryanwiz)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/fixing-a-problem-with-query_posts/#post-1905425)
 * altoidboy: I’m using JournalCrunch on a project, too. Any luck with getting pagination
   on the front page to work??
 * I read your post about the category page pagination, too. Where’d you place that
   PHP code? In the page.php file? Please enlighten me. It sounds like you got that
   to work. Congrats!
 * I really liked using this template, except for those glaring misses. :-/ Thanks!-
   B
 *  Thread Starter [altoidboy](https://wordpress.org/support/users/altoidboy/)
 * (@altoidboy)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/fixing-a-problem-with-query_posts/#post-1905426)
 * See this thread for all the info I have…
 * [http://forums.site5.com/showthread.php?t=30394](http://forums.site5.com/showthread.php?t=30394)

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

The topic ‘Fixing a problem with query_posts’ is closed to new replies.

## Tags

 * [query_post](https://wordpress.org/support/topic-tag/query_post/)

 * 2 replies
 * 2 participants
 * Last reply from: [altoidboy](https://wordpress.org/support/users/altoidboy/)
 * Last activity: [14 years, 11 months ago](https://wordpress.org/support/topic/fixing-a-problem-with-query_posts/#post-1905426)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
