So the Next/Previuos on my index page is broken. It goes to page 2 but doesn't refresh the posts. It will work on my categories and it will work on my posts but it just won't work on the from page. Here's my code:

<?php get_header();?>
<?php include('from.php'); ?>
<div id="content">
<div id="content-main">
        <?php if ($posts) {
                if (get_settings('mistylook_asideid') != "")
                    $AsideId = get_settings('mistylook_asideid');
                function ml_hack($str)
                    return preg_replace('|</ul>\s*<ul class="asides">|', '', $str);
                foreach($posts as $post)
                <?php if ( in_category($AsideId) && !is_single() ) : ?>
                    <ul class="asides">
                        <li id="p<?php the_ID(); ?>">
                            <?php echo wptexturize($post->post_content); ?>
                            <p class="postmetadata"><?php comments_popup_link('(0)', '(1)','(%)')?>  | <a href="<?php the_permalink(); ?>" title="<?php _e('Permalink:','ml');?> <?php echo wptexturize(strip_tags(stripslashes($post->post_title), '')); ?>" rel="bookmark">#</a> <?php edit_post_link(__('(edit)','ml')); ?></p>
                <?php else: // If it's a regular post or a permalink page ?>
                <div id="post-<?php the_ID(); ?>" <?php if (function_exists('post_class')){ post_class(); } else { echo 'class="post"' ;} ?>>
        <div class="posttitle">
          <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e('Permanent Link to','ml');?> <?php the_title(); ?>"><?php the_title(); ?></a></h2>
                    <p class="post-info">            
            <?php the_time(__('M jS, Y','ml')) ?> <?php _e('by','ml');?> <?php the_author_posts_link() ?> <?php edit_post_link(__('Edit','ml'), '', ' | '); ?> </p>          

                <div class="entry">
                    <?php the_content(__('Continue Reading &raquo;','ml')); ?>
                    <?php wp_link_pages(); ?>
                    <p><?php if (function_exists('the_tags')) the_tags(__('Tags: ','ml'), ', ', '<br/>'); ?> </p>

                <p class="postmetadata"><?php _e('Posted in','ml');?> <?php the_category(', ') ?> | <?php comments_popup_link(__('No Comments &#187;','ml'), __('1 Comment &#187;','ml'), __('% Comments &#187;','ml'),'',__('Comments Off','ml')); ?></p>
                <?php comments_template(); ?>
            <?php endif; // end if in category ?>
            else include_once(TEMPLATEPATH.'/notfound.php');
        <p align="center"><?php posts_nav_link(' &#183; ', 'previous page', 'next page'); ?></p>
</div><!-- end id:content-main -->
<?php get_sidebar();?>
<?php get_footer();?>

I'm using a random theme called MistyLook. I've tried working with it but if I have to go to the core files then im stumped... Any suggestions?

1 Answer 1


I had the exact same problem a while ago on one of my themes. My problem was that the theme used query_post to filter out some posts. This caused the pagination to fail.

I think this was the code that solved it:

         if ( is_home() ) {
            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

cat=-19 was the category I wanted to remove. Try to just include it without cat=-19 if you want to include all categories.

The point of this code was to save the variable paged and include it again after I had made a custom query_posts so that WordPress knows what page the reader is on.

  • I think the point of the code was that using query_posts removes all standard included values of the standard query_post in WordPress. This code includes the query variabel again so that WordPress again can understand what page the user is currently on. Commented Jan 12, 2012 at 22:13
  • Ha! I'm querying only 1 category via query_posts. I'll have to play around with that code above to maybe try to fir my situation.
    – Howdy_McGee
    Commented Jan 12, 2012 at 22:16
  • i think if you use the code above as is to get just one category out of the loop it would solve the problem. then all you need to change is the part "cat=(id of category)". Or if you wan to use the category slugg use "category=(slug of category)" Commented Jan 12, 2012 at 23:42
  • Did you find a solution to your problem? :) Commented Jan 16, 2012 at 23:21
  • :D Yes I did very much in part to your answer! Thank you!
    – Howdy_McGee
    Commented Jan 17, 2012 at 0:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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