Previous & Next on Index Page broken

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);
                }
                ob_start('ml_hack');
                foreach($posts as $post)
                {
                    the_post();
                ?>
                <?php if ( in_category($AsideId) && !is_single() ) : ?>
                    <ul class="asides">
                        <li id="p<?php the_ID(); ?>">
                            <?php echo wptexturize($post->post_content); ?>
                            <br/>
                            <p class="postmetadata"><?php comments_popup_link('(0)', '(1)','(%)')?>  | <a href="https://wordpress.stackexchange.com/questions/38760/<?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>
                        </li>
                    </ul>
                <?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>

                <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>
                </div>

                <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(); ?>
            </div>
            <?php endif; // end if in category ?>
            <?php
                }
                 ob_end_flush();
            }
            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:

    <?php
         if ( is_home() ) {
            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
            query_posts("cat=-19&paged=$paged");
         }
    ?>

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.

Leave a Comment